views:

46

answers:

2

The scenario is I would like to be able reference two similar 3rd party assemblies (e.g. assem1 and assem2) which both define a type with the same fully qualified name (e.g. Example.MyType). Is there any way to distinguish between these and refernce them seperately? I believe the answer is no but confirmation or correction would be handy.

Edit: Answered for C# 2.0 and higher below but need an answer in VB.Net 1.1

A: 

Maybe I misunderstood the question; if you want to reference it as part of a project (e.g. in VS), this isn't going to help you. But if you need to reference the type in a config file or whatever, the following does work:

Use the fully qualified name including the assemly name (best if the assembly is strong named), and you can tell them apart. Have a look at Type.AssemblyQualifiedName for more information.

Lucero
Thanks Lucero, need to reference them in code unfortunately.
Rich Oliver
+3  A: 

You can certainly do it in C# - you need to use extern aliases to specify which one you want in each case. Anson Horton has a walkthrough which is useful.

I don't know whether VB has a similar feature.

Of course, it's worth avoiding this situation if you possibly can :)

Jon Skeet
Thanks Jon, this is exactly what i need. Unfortunately its only in C# 2.0 and higher and i need VB.Net 1.1 which i probably should have mentioned. I'll wait a while for other answers before giving you a tick.
Rich Oliver
@Rich: I'm afraid I don't even know if the feature is available in VB. If it is, I'd expect it to be in VB 8 (VS 2005) as well.
Jon Skeet