I'm Keyvan Nayyeri, a 25 years old Ph.D. student at
the Computer Science department of
the University of Texas at San Antonio.
I'm also
a Software Architect and Developer and previously held a B.Sc.
degree in Applied Mathematics.
This is my blog where I publish content about various topics specifically Programming Languages and Compilers, Software
Engineering and Programming.
Sometimes it's mandatory to use a specific version of an assembly when various versions are available in place.
Simplest option is to use <bindingRedirect /> element under <dependentAssembly /> under <assemblyBinding /> in application configuration file.
For example in a configuration file that is presented below, version 1.0.0.0 of KeyvanAssembly is redirected to version 1.0.0.1. Using this configuration file, application applies version 1.0.0.1 of KeyvanAssembly rather than version 1.0.0.0.
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="KeyvanAssembly"
publicKeyToken="f405329a93f8ee7e"
culture="en-us" />
<bindingRedirect oldVersion="1.0.0.0"
newVersion="1.0.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
A nice point is you can force your application to redirect all available versions of an assembly to a specific version using "*" wildcard:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="KeyvanAssembly"
publicKeyToken="f405329a93f8ee7e"
culture="en-us" />
<bindingRedirect oldVersion="*"
newVersion="1.0.0.2"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Now playing: Vangelis - Pulstar
Rui Silva
Jan 05, 2007 5:57 AM
#
fm164
Dec 08, 2008 3:39 PM
#
Hi,
Thanks for the tip.
This looks quite useful, though it did not work for me when I tried it... Is there anything else that is needed to be able to use the "*" wildcard?
Thank you
Pierre-Alain Vigeant
Mar 31, 2009 11:00 AM
#
You cannot specify a * for oldVersion, but you can specify a range.
The following will redirect everything before version 2.0.0.0 to the version 2.0.0.0:
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
Himani
Dec 17, 2009 4:01 AM
#
I have a sharepoint web applicaition containing two site collections. Both reference different versions of the DLL in gac.
I need to specify the version to use in the assemblies section. But as soon as I do that, the other site breaks down. So, I tried to place binding redirect so that erquest for the old version go to the old version. but somehow it doesnt work. It still shows me the same error (that the type exists in both verisons). If i remove the assemby name from assemblies seciton then the other iste works and the first one stops working which is using the newer veriosn. Please help!
Leave a Comment