[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

Confused about Assembly naming with Namespace

Elmo Watson

9/7/2007 8:23:00 PM

OK - here's the situation - I want my namespace to be:
MyCompanyName.Controls

I want my custom web control to be called:
MyControl (myControl.dll, or MyCompanyName.Controls.MyControl.dll - whatever
is expected)

Then, when I declare it in the project, it will be like this:
Dim ctl as new MyCompanyName.Controls.MyControl

However, after putting:
MyControl
in the assembly name box of the Application Tab (MyProject)
and
MyCompanyName.Controls
in the Root Namespace textbox, the only way to get it in code is:
Dim ctl as new
MyCompanyName.Controls.MyCompanyName.Controls.MyControl.myControl

In my AssemblyInfo.vb, I see:
<Assembly: AssemblyTitle("MyControl")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("MyCompanyName")>
<Assembly: AssemblyProduct("MyControl")>

where am I going wrong?


1 Answer

CarlosS

9/9/2007 12:28:00 AM

0

The reason is that in VB.Net, the namespace declaration gets appended to the root namespace defined in the project properties. So if you have MyCompanyName.Controls as your root namespace, in code you should have this.<br /><br />Begin Class MyControl<br />...<br />End Class<br /><br />Results in the control named MyCompanyName.Controls.MyControl<br /><br />not <br /><br />Begin Namespace MyCompanyName.Controls.MyControl<br /> Begin Class MyControl<br /> ...<br /> End Class<br />End Namespace<br /><br />Results in the control named MyCompanyName.Controls.MyControl.MyControl<br /><br />In the first scenario, since there is no namespace defined, the root namespace gets appended to nothing, resulting in the root namespace. In the second scenario, the root namespace gets appended to the namespace declare in code which was MyCompanyName.Controls.MyControl, resulting in the really long namespace you see.<br /><br />Carlos S<br />BlackBelt Solutions