Reputation: 31
I have a project which compares output generated in two different code bases. So I have to use both DLLs, which have the same name, in my application. I have created two separate class libraries and added each DLL to one of them, then added references to these class libraries to my main project. When I call the methods in the first class library, all works fine and the DLL specified in its reference is picked correctly. But when the second instance is called, it takes the DLL path from the first instance and not the one referred in that class library.
How do I prevent this collision?
Upvotes: 2
Views: 175
Reputation: 22191
You can either fully qualify the names inline where you declare them or you can use an alias in your imports statement at the top of the file. So if you have a class Foo
in Namespace1.Some.Element
and also in Namespace2.Some.Element
, you could do the following via aliases:
Imports alias1 = Namespace1.Some.Element
Imports alias2 = Namespace2.Some.Element
Then you would use it like so:
Dim myFoo1 as new alias1.Foo()
Dim myFoo2 as new alias2.Foo()
Or you could do it with a fully qualified name like so:
Dim myFoo1 as new Namespace1.Some.Element.Foo()
Dim myFoo2 as new Namespace2.Some.Element.Foo()
For more information look at the documentation on MSDN.
NOTE: I'm mainly a C# developer, so I appologize if my syntax is slightly off.
Upvotes: 2