0

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".

  • What is wrong?
  • It is namespae a sort of path how to retrieve the Class?
  • Why I cannot use a different name?

Thanks guys for you help!

2
  • Apparently there's no error(but for the use of "namesCaPe" instead of namesPaCe, but i think it's just a typo) are you sure the error comes from that namespace? can you provide any more information? Commented Nov 10, 2010 at 14:14
  • Error is Missing Assembly Reference, YES I think is the user of namespace, infact if i use the automatic name version it works. if I changed with my custom name it does not? any ideas? Can i change the name of namespace without change the structure of files? I use VS as WEB PROJECT..thanks Commented Nov 10, 2010 at 14:28

3 Answers 3

1

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.
Sign up to request clarification or add additional context in comments.

3 Comments

Hi Lee, I understand your point, and I was thinking the same, but when I change the name for namespace I receive the same error. All my code has been BUILD as CMS.DLL..... is for this reason that I cannot use anywhere else a custom namespace Wdg.Cms.Common???? thanks for now!
HI lee, sorry did you test it as WEB PROJECT or WEB SITE in VS? thanks
I tested it as Web Site in VS
1

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

Comments

0

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.

1 Comment

Thanks Lane, sorry but my questions is WHY I CANNOT give the name scape as I want?? looks like more a FILE PATH.. thansk for your time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.