By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,712 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,712 IT Pros & Developers. It's quick & easy.

Global namespace problem

P: n/a
I have 2 external assemblies A1 and A2 that both define class X in the global
namespace. I need to use both assemblies in my VB project but the names X are
ambiguous. How can I get around this problem?

Is there a way to refer to the assembly, f.ex. A1.X and A2.X (this syntax
does not compile).

Or can I change the name X in the Imports directive? Again the problem is
how do I refer to the 2 different X'es in assemblies A1 and A2:

Imports A1_X = A1.X ' Does not compile

BTW, is there any way to explicitly refer to the global namespace, like C++
::?

Any bright ideas out there?
Nov 21 '05 #1
Share this Question
Share on Google+
10 Replies

P: n/a
"anders" <an****@discussions.microsoft.com> schrieb
I have 2 external assemblies A1 and A2 that both define class X in
the global namespace. I need to use both assemblies in my VB project
but the names X are ambiguous. How can I get around this problem?

Is there a way to refer to the assembly, f.ex. A1.X and A2.X (this
syntax does not compile).

Or can I change the name X in the Imports directive? Again the
problem is how do I refer to the 2 different X'es in assemblies A1
and A2:

Imports A1_X = A1.X ' Does not compile

BTW, is there any way to explicitly refer to the global namespace,
like C++ ::?

Any bright ideas out there?

Did you leave the "root namespace" of the two assemblies empty? If you
didn't, you can use the full qualified name.
Armin

Nov 21 '05 #2

P: n/a
Armin, how do you set the root namespace? I get very confused regarding the
namespace heirchy
--
Dennis in Houston
"Armin Zingler" wrote:
"anders" <an****@discussions.microsoft.com> schrieb
I have 2 external assemblies A1 and A2 that both define class X in
the global namespace. I need to use both assemblies in my VB project
but the names X are ambiguous. How can I get around this problem?

Is there a way to refer to the assembly, f.ex. A1.X and A2.X (this
syntax does not compile).

Or can I change the name X in the Imports directive? Again the
problem is how do I refer to the 2 different X'es in assemblies A1
and A2:

Imports A1_X = A1.X ' Does not compile

BTW, is there any way to explicitly refer to the global namespace,
like C++ ::?

Any bright ideas out there?

Did you leave the "root namespace" of the two assemblies empty? If you
didn't, you can use the full qualified name.
Armin

Nov 21 '05 #3

P: n/a
Can you elaborate, please. You have lost me!

"Armin Zingler" wrote:
"anders" <an****@discussions.microsoft.com> schrieb
I have 2 external assemblies A1 and A2 that both define class X in
the global namespace. I need to use both assemblies in my VB project
but the names X are ambiguous. How can I get around this problem?

Is there a way to refer to the assembly, f.ex. A1.X and A2.X (this
syntax does not compile).

Or can I change the name X in the Imports directive? Again the
problem is how do I refer to the 2 different X'es in assemblies A1
and A2:

Imports A1_X = A1.X ' Does not compile

BTW, is there any way to explicitly refer to the global namespace,
like C++ ::?

Any bright ideas out there?

Did you leave the "root namespace" of the two assemblies empty? If you
didn't, you can use the full qualified name.
Armin

Nov 21 '05 #4

P: n/a
"anders" <an****@discussions.microsoft.com> schrieb
"anders" <an****@discussions.microsoft.com> schrieb
I have 2 external assemblies A1 and A2 that both define class X
in the global namespace. I need to use both assemblies in my VB
project but the names X are ambiguous. How can I get around this
problem?

Is there a way to refer to the assembly, f.ex. A1.X and A2.X
(this syntax does not compile).

Or can I change the name X in the Imports directive? Again the
problem is how do I refer to the 2 different X'es in assemblies
A1 and A2:

Imports A1_X = A1.X ' Does not compile

BTW, is there any way to explicitly refer to the global
namespace, like C++ ::?

Any bright ideas out there?

Did you leave the "root namespace" of the two assemblies empty? If
you didn't, you can use the full qualified name.


Can you elaborate, please. You have lost me!


In each assembly, you can set the "root namespace" in the project
properties. That's the namespace all classes and namespaces are placed in.
If you left them (in both projects) empty, you probably really have got a
problem because the full qualified name is the same. If you didn't leave it
empty, you could use the full qualified name to specify the class. If A1 ist
the root namespace of assembly A1, then A1.X is the full qualified class
name of the class in assembly A1.
Armni

Nov 21 '05 #5

P: n/a
"anders" <an****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
I have 2 external assemblies A1 and A2 that both define class X in
the global namespace. I need to use both assemblies in my VB project
but the names X are ambiguous. How can I get around this problem?


Either fully-qualify all references to each class, as in

sData = NS1.NS2.NS3.X.StringMethod()
sData = NS4.NS5.NS6.X.StringMethod()

or change the Imports statements so add your own "alias", as in

Imports A1=NS1.NS2.NS3
Imports A2=NS4.NS5.NS6

sData = A1.X.StringMethod()
sData = A2.X.StringMethod()

(I use the same thing with the VisualBasic namespace, just to jog my
memory about the potential differences, as in

sItems = VB.Split( "string with line breaks", vbCrLf )

HTH,
Phill W.
Nov 21 '05 #6

P: n/a
I found that if I don't specifically provide a root namespace, then when I
create a new project, the name of the directory if used.
--
Dennis in Houston
"Phill. W" wrote:
"anders" <an****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
I have 2 external assemblies A1 and A2 that both define class X in
the global namespace. I need to use both assemblies in my VB project
but the names X are ambiguous. How can I get around this problem?


Either fully-qualify all references to each class, as in

sData = NS1.NS2.NS3.X.StringMethod()
sData = NS4.NS5.NS6.X.StringMethod()

or change the Imports statements so add your own "alias", as in

Imports A1=NS1.NS2.NS3
Imports A2=NS4.NS5.NS6

sData = A1.X.StringMethod()
sData = A2.X.StringMethod()

(I use the same thing with the VisualBasic namespace, just to jog my
memory about the potential differences, as in

sItems = VB.Split( "string with line breaks", vbCrLf )

HTH,
Phill W.

Nov 21 '05 #7

P: n/a
A1 and A2 are OEM products so I don't have the source code or project files
to fiddle with. This begins to look like a serious problem in .NET languages.
The VB.NET Imports directive gives you the possibility to resolve name
clashes between named namespaces but NOT clashes within the global namespace!

I also looked into C# and Managed C++ and could not find any solution to
this problem.

"Armin Zingler" wrote:
"anders" <an****@discussions.microsoft.com> schrieb
"anders" <an****@discussions.microsoft.com> schrieb
> I have 2 external assemblies A1 and A2 that both define class X
> in the global namespace. I need to use both assemblies in my VB
> project but the names X are ambiguous. How can I get around this
> problem?
>
> Is there a way to refer to the assembly, f.ex. A1.X and A2.X
> (this syntax does not compile).
>
> Or can I change the name X in the Imports directive? Again the
> problem is how do I refer to the 2 different X'es in assemblies
> A1 and A2:
>
> Imports A1_X = A1.X ' Does not compile
>
> BTW, is there any way to explicitly refer to the global
> namespace, like C++ ::?
>
> Any bright ideas out there?
Did you leave the "root namespace" of the two assemblies empty? If
you didn't, you can use the full qualified name.


Can you elaborate, please. You have lost me!


In each assembly, you can set the "root namespace" in the project
properties. That's the namespace all classes and namespaces are placed in.
If you left them (in both projects) empty, you probably really have got a
problem because the full qualified name is the same. If you didn't leave it
empty, you could use the full qualified name to specify the class. If A1 ist
the root namespace of assembly A1, then A1.X is the full qualified class
name of the class in assembly A1.
Armni

Nov 21 '05 #8

P: n/a
You don't seem to answer my question. How do you fully qualify X which is in
the global namespace of both assemblies A1 and A2?

"Phill. W" wrote:
"anders" <an****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
I have 2 external assemblies A1 and A2 that both define class X in
the global namespace. I need to use both assemblies in my VB project
but the names X are ambiguous. How can I get around this problem?


Either fully-qualify all references to each class, as in

sData = NS1.NS2.NS3.X.StringMethod()
sData = NS4.NS5.NS6.X.StringMethod()

or change the Imports statements so add your own "alias", as in

Imports A1=NS1.NS2.NS3
Imports A2=NS4.NS5.NS6

sData = A1.X.StringMethod()
sData = A2.X.StringMethod()

(I use the same thing with the VisualBasic namespace, just to jog my
memory about the potential differences, as in

sItems = VB.Split( "string with line breaks", vbCrLf )

HTH,
Phill W.

Nov 21 '05 #9

P: n/a
"anders" <an****@discussions.microsoft.com> schrieb

In each assembly, you can set the "root namespace" in the project
properties. That's the namespace all classes and namespaces are
placed in. If you left them (in both projects) empty, you probably
really have got a problem because the full qualified name is the
same. If you didn't leave it empty, you could use the full
qualified name to specify the class. If A1 ist the root namespace
of assembly A1, then A1.X is the full qualified class name of the
class in assembly A1.

A1 and A2 are OEM products so I don't have the source code or
project files to fiddle with. This begins to look lik
easeriousproblemin.NETlanguages. The VB.NET Imports directive gives
you the possibility to resolve name clashes between named namespaces
but NOT clashes within the global namespace!

I also looked into C# and Managed C++ and could not find any
solution to this problem.

I do not really see the problem. I do not even have the possibilty to set
references to two assemblies containing conflicting class names because I
get this error:

"bla\ClassLibrary2\Class1.vb(1): class "Class1" and class "Class1", defined
in "bla\ClassLibrary1\Class1.vb", conflict in namespace "<Default>""

You get this message if you create a new project, add two new
classlibraries, delete the root namespace in both libraries and try to set a
reference from the main project to both classlibraries.
Are you sure that the classes are not contained in a namespace in both
assemblies? Have a look @ the object browser.

Armin

Nov 21 '05 #10

P: n/a
Define "OEM products".

If these are commerical products that are shipping /without/ using
well-defined Namespaces, I'd think long and hard before making use
of them.

If you have no other recourse, you may have to write your own,
(properly Namespaced) "wrapper" assembly around one or other
of them, exposing all the same properties, method, etc.

Regards,
Phill W.

"anders" <an****@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
A1 and A2 are OEM products so I don't have the source code or
project files to fiddle with. This begins to look like a serious problem
in .NET languages. "Armin Zingler" wrote:
"anders" <an****@discussions.microsoft.com> schrieb
> "anders" <an****@discussions.microsoft.com> schrieb
> > I have 2 external assemblies A1 and A2 that both define class X
> > in the global namespace. I need to use both assemblies in my VB
> > project but the names X are ambiguous. How can I get around this
> > problem?
> >
> > Is there a way to refer to the assembly, f.ex. A1.X and A2.X
> > (this syntax does not compile).
> >
> > Or can I change the name X in the Imports directive? Again the
> > problem is how do I refer to the 2 different X'es in assemblies
> > A1 and A2:
> >
> > Imports A1_X = A1.X ' Does not compile
> >
> > BTW, is there any way to explicitly refer to the global
> > namespace, like C++ ::?
> >
> > Any bright ideas out there?
>
>
> Did you leave the "root namespace" of the two assemblies empty? If
> you didn't, you can use the full qualified name.

Can you elaborate, please. You have lost me!


In each assembly, you can set the "root namespace" in the project
properties. That's the namespace all classes and namespaces are placed in. If you left them (in both projects) empty, you probably really have got a problem because the full qualified name is the same. If you didn't leave it empty, you could use the full qualified name to specify the class. If A1 ist the root namespace of assembly A1, then A1.X is the full qualified class
name of the class in assembly A1.
Armni

Nov 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.