Why assembly namespace coming twice?
I am calling my business layer project in Web Project. I added refress business layer project to Web. When I call class in BL project, I need to write twice this namespace. I dont know why it is coming.
MyCompanyN开发者_Go百科ame.HRHead.DataLayer.MyCompanyName.HRHead.DataLayer.User
I suppose to call
MyCompanyName.HRHead.DataLayer.User
In my BL project I defined all classes namespace is MyCompanyName.HRHead.DataLayer
Please help me out.
Thanks in advance
In VB, the project has a default namespace - and this is applied as a prefix to whatever you write in the source. This is not like C#, where the project's default namespace just affects the source code template when you add a new item . So if your project default namespace is Foo.Bar
and you also declare a namespace of Foo.Bar.Baz
, the full namespace will be Foo.Bar.Foo.Bar.Baz
.
I suggest you either change the project settings or just remove the common prefix from your source code.
I am assuming certain things from the tags that you are using. You are using an assembly written in VB.NET in your other project. VB.NET project properties include an attribute "default namespace" and that might be set with the namespace that you have defined explicitly at the top of your classes. Remove the default namespace (uncheck it) in the project properties and recompile the same.
If you are using c#, you can use this code segment :
using MyCompanyName.HRHead.DataLayer.User = MyCompanyName.HRHead.DataLayer.MyCompanyName.HRHead.DataLayer.User;
So you can use the namespace MyCompanyName.HRHead.DataLayer.User instead of MyCompanyName.HRHead.DataLayer.MyCompanyName.HRHead.DataLayer.User
Regards, pro
you can also access the namespace if you start from the global namespace in C# like this:
global::MyCompanyName.HRHead.DataLayer.User
精彩评论