I have to agree with Jon, you should avoid reusing the same namespace and
type name repeatedly.
"Jon Skeet [C# MVP]" <(E-Mail Removed)> wrote in message
news:05badf78-c79a-465b-bf38-(E-Mail Removed)...
On Jun 23, 3:28 pm, qglyirnyf...@mailinator.com wrote:
> Suppose that you have two dlls (ClassLibrary1.dll and
> ClassLibrary2.dll).
>
> Now suppose that both dlls have the same class declared on them using
> the exact same name space and class name, for example, supposed both
> dlls have the following snippet of code:
>
> namespace SomeNameSpace
> {
> public class Class1
> {
> }
>
> }
>
> Now supposed you reference both dlls into your main project and add
> the following snippet of code into this main project.
>
> SomeNameSpace.Class1 cls = new SomeNameSpace.Class1();
>
> If you try to compile the project you will get an error message
> stating that “SomeNameSpace.Class1()” exist in both dlls and so the
> compiler can’t choose which one to select.
>
> Is there a way to specify what dll to use when instantiating Class1?
Yes, assuming you're using C# 2 or later. You need to use a feature
called "extern aliases" - that should be enough to get you going with
a good search. However, I'd stress that if you can *possibly* avoid
this, do so.
Jon
|