GibboK
GibboK

Reputation: 73918

Using Namespaces

I have a "Web Project" in VS. File structure

- AdminCms
  - Sections
    - CmsAuthors
- App_Code
  - Business Logics
    - Common
       - BuilderStrings.cs
    - DataAccess
      -CmsModel.edmx

When I Build the Project VS in BIN Create a Cms.dll file.

In file "BuilderStrings.cs" I use:

namespace Cms.App_Code.BusinessLogics.Common

Using this code from folder "CmsAuthors"

using Cms.App_Code.BusinessLogics.Common;

As so far all is working fine.

Now for my understanding I should be able to name the namespace as I want ex:

namescape Wdg.Cms.Common

so if I use:

using Wdg.Cms.Common;

Script should be work just fine. Instead I get an error "Missing Assembly Reference".

Thanks guys for you help!

Upvotes: 0

Views: 225

Answers (3)

bla
bla

Reputation: 5480

It is perfectly fine. Have you saved and rebuild your project?

** I did get the error for the first time as I didn't save my changes in app_code.

  1. Nothing wrong here.
  2. The main purpose of having namespace is to avoid class name collision. For example, you have StringBuilder.cs in App_Code/Admin and App_Code/Common, you can differentiate them by using name space: Wdg.Cms.Common.StringBuilder and Wdg.Cms.Admin.StringBuilder
  3. You can use a different name.

Upvotes: 1

Giorgio Minardi
Giorgio Minardi

Reputation: 2775

namespaces should be defined using conventions, according to Microsoft "The general rule for naming namespaces is to use the company name followed by the technology name and optionally the feature and design as follows: CompanyName.TechnologyName[.Feature][.Design] ". Have a look here : http://msdn.microsoft.com/en-us/library/893ke618%28VS.71%29.aspx

http://msdn.microsoft.com/library/ms229002

http://10rem.net/articles/net-naming-conventions-and-programming-standards---best-practices

Upvotes: 1

Lane
Lane

Reputation: 2719

You should keep your namespaces the same throughout your solution. You've used Cms.App_Code.BusinessLogics.Common in several places, so continue to use that in all places.

Your usage of Wdg.Cms.Common may be the cause of your Missing Assembly error.

Upvotes: 0

Related Questions