Global namespace problem in .NET


G

Guest

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, not same class) in the global namespace. I need to use both X'es in my
project. How do I fully qualify the X'es to avoid the name clash between X
from A1 and X from A2.

The using statement provides a way of aliasing clashing names from named
namespaces but it does NOT give the possibility to resolve name clashes in
the global namespace. Or is it possible?

Any bright minds out there who have a solution?

Otherwise, this seems to be a serious problem with .NET languages. I hope
somebody from Microsoft sees this and gets this problem fixed.
 
Ad

Advertisements

T

Tim Haughton

How large is the surface area of each of your OEM assemblies? Could you
create namespaced proxies for them?

Please shoot the supplier of any assemblies using global types. It might
seem excessive now, but unless we stop these people reproducing, they'll
keep at it.

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
 
G

Guest

Shooting people is hardly the solution to this problem. Inevitably there will
be clashes in the global name space even when you use namespaces. The
outermost namespace of every assembly is in the global scope and a name clash
is always possible so there should be a mechanism of resolving them!

How would you create a namespaced proxy?
 
T

Tim Haughton

anders said:
Shooting people is hardly the solution to this problem.

No, it isn't. But it will help prevent the problem from recurring, and will
also make you feel a lot better.
Inevitably there will
be clashes in the global name space even when you use namespaces. The
outermost namespace of every assembly is in the global scope and a name clash
is always possible so there should be a mechanism of resolving them!

I've been developing in C# for over 4 years now and have never encountered a
single naming clash. But then I've never used (or seen anyone use) the
global namespace.
How would you create a namespaced proxy?

Create an assembly for each OEM assembly you want to wrap. In the namespace
of your choice (not global) create a class or classes that essentially
forward on the calls and data to the OEM assembly. Each of your proxy
assemblies will include only the OEM assembly that it is wrapping, hence no
conflict. Then, your app code uses your proxies and doesn't reference the
OEM assemblies directly. Problem solved.

But like I said, I've never had to give a second's thought to resolving
naming conflicts before today since I've never come across one, so there
might be a trivial solution out there.

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
 
Ad

Advertisements

C

Christof Nordiek

anders said:
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, not same class) in the global namespace. I need to use both X'es in
my
project. How do I fully qualify the X'es to avoid the name clash between X
from A1 and X from A2.

The using statement provides a way of aliasing clashing names from named
namespaces but it does NOT give the possibility to resolve name clashes in
the global namespace. Or is it possible?

Any bright minds out there who have a solution?

Otherwise, this seems to be a serious problem with .NET languages. I hope
somebody from Microsoft sees this and gets this problem fixed.
Yes, anybody from Microsoft saw it, and it will be fixed in VS2005/C#2.0 ;-)

Christof
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top