Note that there are some explanatory texts on larger screens.

plurals
  1. POError attempting to use "extern alias" to reference two different DLLs with the same namespace (Visual Studio 2010)
    primarykey
    data
    text
    <p>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 <a href="http://blogs.msdn.com/b/ansonh/archive/2006/09/27/774692.aspx" rel="nofollow">http://blogs.msdn.com/b/ansonh/archive/2006/09/27/774692.aspx</a>.</p> <p>However, when I attempt to do this, I run into a couple of issues that I have been unable to resolve.</p> <p>Here's what I have done:</p> <ol> <li>Create a project for a class library, called V1.Model which has class Model.MyClass. Sign this assembly.</li> <li>Create another project for a class library, called Model, which also has class Model.MyClass. Sign the assemply.</li> <li>Copy the DLLs created from the above two projects into a folder, say Versions, and rename them (V1.Model -> V1.Model.dll, Model -> V2.Model.dll).</li> <li>Create a console application project, called Test, which references V1.Model.dll and V2.Model.dll.</li> <li>Change the "Aliases" property of the reference to V1.Model to "V1".</li> <li>Change the "Aliases" property of the reference to V2.Model to "V2".</li> <li><p>Create the following code which references both assemplies:</p> <p>extern alias V1;<br> extern alias V2; </p> <p>static void Main(string[] args)<br> {<br> var v1 = new V1::Model.MyClass();<br> var v2 = new V2::Model.MyClass();<br> } </p></li> <li><p>Build and run Test</p></li> </ol> <p>When I do this, there are a couple of issues. </p> <p>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.</p> <p>Two, when I run the application, I get the following error: </p> <blockquote> <p>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.</p> </blockquote> <p>Any ideas what I am doing wrong?</p> <p>Thanks, Eric</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload