Friday, December 16, 2011

Redirecting Assembly Versions

When you build a .NET Framework application against a specific version of a strong-named assembly, the application uses that version of the assembly at run time. However, sometimes you might want the application to run against a newer version of an assembly. An application configuration file, machine configuration file, or a publisher policy file can redirect one version of an assembly to another.
The simplest, is to modify the assembly bindings to redirect one version of an assembly to another.
In the example below the bindingRedirect allows requests for version 1.0.0.0 of this particular assembly to be serviced by version 2.0.0.0. So long as we’re sure the deserializing functionality is compatible, this solves the problem without having to change any code.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
 <dependentAssembly>
 <assemblyIdentity name="Configuration" publicKeyToken="........." culture=""/>
 <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
 <codeBase href="C:\bin\Configuration.dll" version="2.0.0.0" />
 </dependentAssembly>
</assemblyBinding>

Submit this story to DotNetKicks

1 comment: