[RESOLVED] Can you Alias a Project level Imports statement?
I know you can alias an Imports statement in code:
Code:
Imports xyz = ProjectABC.ClassABC
But if I want to use the Project Properties, Reference tab to select a namespace to allow a project-wide setting, is it possible to alias that namespace?
Thanks!
Re: Can you Alias a Project level Imports statement?
huh? o.O ???? I don't follow...
wait, you mean you want to alias namespaces of referenced assemblies? the imports doesn't care where the assembly is... you can alias any namespace you want.
-tg
Re: Can you Alias a Project level Imports statement?
techgnome, say I have a form and in that form I do the imports:
Code:
Imports xyz = ProjectABC.ClassABC
...
Dim userName as String = xyz.UserName
Now, if I have form 2 I can't do this:
Code:
Dim userName as String = xyz.userName
without declaring another Imports statement.
I know you can do import at the project level as I mentioned in my first post but that doesn't appear to allow you to alias the imported namespace. So the above line of code would become
Code:
Dim userName as String = SomeName.ClassName.UserName
and I'd have to use that fully qualified name everyplace I needed the reference, when all I want to use is xyz.userName
Does that make more sense?
(Edit: I might add that I WANT some kind of qualifier so that when reading the code you know where the member reference originates. I just don't want the full name)
Re: Can you Alias a Project level Imports statement?
The bottom half of the References page of the project properties has a text box above the list of namespaces. You just type your aliased import, i.e. xyz = ProjectABC.ClassABC, into that box and then click the Add button beside it.
Re: Can you Alias a Project level Imports statement?
Thanks jmc, that actually rang a bell when I read your message so I think I encountered that tip somewhere else in the past.