Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why assembly namespace coming twice?

Tags:

c#

asp.net

vb.net

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.

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

like image 274
James123 Avatar asked Feb 27 '23 07:02

James123


2 Answers

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.

like image 108
Jon Skeet Avatar answered Mar 05 '23 09:03

Jon Skeet


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.

like image 22
Kangkan Avatar answered Mar 05 '23 08:03

Kangkan