Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VB and Namespaces Arggg
Message
De
04/03/2008 14:55:08
 
 
À
04/03/2008 13:40:01
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01298281
Message ID:
01298599
Vues:
22
>Hi Viv,
>
>
>>>Ok, I am loosing my mind. I have been working in C# for awhile and now doing a project in VS2008 with VB. I am trying to use namespaces but seems it works differently than in C#. I don't remember this to be the case when I did some VB back in VS2003.
>>>
>>>I have a project named:
>>>MyApplication.Web.Base
>>>In this I have a folder named Forms and the namespace on my base form is:
>>>Namespace MyApplication.Web.Base.Forms with a class of WebPageBase
>>>
>>>When I try to reference this inside the web application project I did this:
>>>Import MyApplication.Web.Base and tried to reference Forms.WebPageBase
>>>
>>>Intellisense tells me I have to reference this full namespace
>>>MyApplication.Web.Base.MyApplication.Web.Base.Forms.WebPageBase
>>>
>>>This seems a little silly to me. Is there some kind of automatic "Add the project name to the namespace" setting I need to turn off somewhere?
>>
>>Sounds like you may be importing another namespace which also has a Forms element (I was going to suggest System.Windows.Forms but since this is a web project you shouldn't have that one anyway)
>>
>>IAC, if there is a neccessary conflict you could use an alias in the Imports statement.
>
>I did a little reading last night and it appears VB adds the project name as a root level namespace. If I remove that portion from the namesapce declaration it fixes most of the problem. I don't really like this as the namespace declaration is not complete when you are looking at the source as you have to add the project name to it in your head.

It's set in the project properties - Application/Root namespace.
You can blank it out if you prefer

>I also find another issue that you are mention above. For instance if I do an import of:
>Import MyName.MyProjectA
>Import MyName.MyProjectB
>
>And then both of those projects have a class named Enums it becomes ambiguous when I try to reference it in code. I am apparently not allowed to use the full qualified name such as MyName.MyProjectA.Enums.ErrorLevel = since the Import is there. How do I use an alias in the import? Would that get around this?
Imports EnumsA = MyName.MyProjectA.Enums
Imports EnumsB = MyName.MyProjectB.Enums
'Then refer as:
EnumsA.ErrorLevel
EnumsB.xxx
Update: I also don't understand why you have any problem using a fully qualified namespace - that should *always* be available (assuming the project has a reference in the first place)

HTH,Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform