Nik's Technology Blog

Travels through programming, networks, and computers

Ambiguous DLLs

We’ve just been testing an upgrade our CMS and come across a few problems concerning newer versions of assemblies interfering with older versions stored in the GAC.

The solution is to use a binding redirect in Web.Config to tell the framework to use the latest version.  For more info see Redirecting Assembly Versions.

   1: <runtime>
   2:   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
   3:     <dependentAssembly>
   4:       <assemblyIdentity name="Immediacy.Web" publicKeyToken="b35b2a186fcebe46"/>
   5:       <bindingRedirect oldVersion="6.1.0.0" newVersion="6.2.0.0"/>
   6:     </dependentAssembly>
   7:   </assemblyBinding>
   8: </runtime>

To get the publicKeyToken for the DLL you need to open a Visual Studio command prompt and navigate to the folder containing the DLL and type:

SN –T assemblyname.dll

This will give you the publicKeyToken to put in the assembly identity.

Alternatively you could remove the old version of the DLL from the GAC by using this command with the Global Assembly Cache Tool

gacutil /u Immediacy.Web, Version=6.1.0.0, Culture="en",PublicKeyToken=b35b2a186fcebe46

Comments are closed