473,383 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Global namespace problem

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
10 6625
"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
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
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
"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
"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
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
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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

88
by: Tim Tyler | last post by:
PHP puts most of its functions into a big flat global namespace. That leads to short function names - but creates a namespace minefield for programmers. Lots of the functions are legacies from...
2
by: Wat | last post by:
If a class is not given a namespace, what does this imply? From inside of the class, if to call global functions, should global scope :: be used at all? If global scope :: used, what benefits...
2
by: Tony Johansson | last post by:
Hello! I'm reading a book about C++ and there is something that I don't understand so I ask you. Below I have the text from the book and the code from the file where main is located and some...
3
by: seberino | last post by:
At top of a module I have an integer like so... foo = 4 In a function in that module I know I need to do 'global foo' to get at the value 4. .... IIRC, for dictionaries you DO NOT have...
4
by: anders | last post by:
I already asked this question in the VB.NET group but as C# seems to have the same problem, I'll try here, too. I have 2 external OEM assemblies A1 and A2 that both define class X (same name,...
3
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a...
8
by: Thomas Coleman | last post by:
Ok, I've obviously discovered that Global.aspx has been completely changed in ..NET 2.0. However, I haven't figured out how to declare a constant that's available to any page in my application...
3
by: mrstephengross | last post by:
Hi folks. I've got a weird situation--gcc doesn't like the folllowing code snippet, but I don't know if it's correct or not. Here's the situation: In the global namespace, I've got a operator<<...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.