Linking and redirecting an assembly

I have an exe that references a dll - for this example I will call it TestDLL.dll.
The EXE is written in C #, and the DLL is written to VB.Net.

I created a demo assembly version of the DLL - for example, TestDLL.dll version 1.0.0.0.
I want to compile an exe with reference to the demo version of the DLL (1.0.0.0). Subsequently - I want the EXE to use the same DLL, but the one that I put in the GAC, any version.
To do this, I set the Copy Local property of the DLL link to FALSE .

My goal, for example, is that after compilation I will put the build version 2.1.6.0 in the GAC TestDLL.dll, and the EXE will find it using the assembly redirect binding. For this, I used the configuration file. I used this link to create it:
http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.71).aspx

So my configuration file looks something like this:

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
         <assemblyIdentity name="myAssembly"
                           publicKeyToken="32ab4ba45e0a69a1"
                           culture="en-us" />
         <!-- Assembly versions can be redirected in application, publisher policy, or machine configuration files. -->
         <bindingRedirect oldVersion="1.0.0.0"
                          newVersion="2.1.6.0"/>
       </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>

The problem is that after doing all this, I run the EXE and get a known error when accessing the DLL: System.IO.FileNotFoundException: Failed to load the file or assembly "TestDLL, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = 9d8162944bd6fdc7 "or one of its dependencies. The system cannot find the specified file. File name: 'TestDLL, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = 9d8162944bd6fdc7'

, EXE DLL, . , "" GAC , - EXE .

- , ?

+5
1

, publicKeyToken. , , publicKeyToken="32ab4ba45e0a69a1", MSDN. , . (1.0.0.0 2.1.6.0), . , sn.exe , ( , publicKeyToken="9d8162944bd6fdc7"):

sn.exe -Tp myassembly.dll

, , , .

, culture="en-us", ? culture="Neutral".

, , GAC.

+11

All Articles