Reputation: 2067
I've read a couple of articles which lead me to believe that it's possible to reference two DLLs with the same namespace in the same project - see http://blogs.msdn.com/b/ansonh/archive/2006/09/27/774692.aspx.
However, when I attempt to do this, I run into a couple of issues that I have been unable to resolve.
Here's what I have done:
Create the following code which references both assemplies:
extern alias V1;
extern alias V2;
static void Main(string[] args)
{
var v1 = new V1::Model.MyClass();
var v2 = new V2::Model.MyClass();
}
Build and run Test
When I do this, there are a couple of issues.
One, the V1.Model.dll is not copied to the bin directory. (In fact, if I include many versions of the same namespace, it appears that only the DLL with the most recent version is copied). Of course, I can workaround this issue by manually copying the dll to the bin directory, but I am curious why this is necessary. Also, note that I have changed the "Copy Local" property to true for both references.
Two, when I run the application, I get the following error:
Could not load file or assembly 'Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d89c4561a79dd027' or one of its dependencies. The system cannot find the file specified.
Any ideas what I am doing wrong?
Thanks, Eric
Upvotes: 2
Views: 1898
Reputation: 34401
When the system tries to locate an assembly called "Model", it will look for a file called "Model.dll". I think this can be resolved by GAC-ing the assemblies.
Upvotes: 1