Over the last year or so I have been working predominantly with ASP.NET and for that reason alone I have tended to not have to deal directly with the GAC and some of its finer benefits (specifically side by side execution). So I thought I would go over one of the benefits of bindingRedirect.

Obviously the prerequisite to installing assemblies in the GAC include creating strong name key file, associating it with the assembly and installing it in the GAC, and so I created two version of an assembly.

image

In my test application I configured and tested against 1.1.0.0, and so based on that fact, the test application would call 1.1.0.0 . In order to ensure that I can use version 1.2 at will  I needed to create and\or modify the App.Config file to use the bindingRedirect element as follows.

<configuration>
    <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                    <dependentAssembly>
                            <assemblyIdentity name="TestLib"  /> 
                            <bindingRedirect oldVersion="1.1.0.0" newVersion="1.2.0.0"/>
                    </dependentAssembly> 
            </assemblyBinding>
    </runtime>
</configuration>

If you are dealing with multiple applications that need to be upgraded, or indeed downgraded, you should also consider using a Publisher Policy File or modifying the Machine Config File.