Redirecting Assembly Versions

How to redirect an application to run against 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. You can use the .NET Framework Configuration tool (Mscorcfg.msc) to redirect assembly versions at both the application level and the machine level, or you can directly edit the configuration file.

Note: You cannot redirect versions for assemblies that are not strong-named. The common language runtime ignores the version for assemblies that are not strong-named.

Redirecting Assembly Versions Using Publisher Policy

Vendors of assemblies can state that applications should use a newer version of an assembly by including a publisher policy file with the upgraded assembly. The publisher policy file, which is located in the global assembly cache, contains assembly redirection settings. Vendors use publisher policies only when the new assembly is backward compatible with the assembly being redirected.

You can bypassing Publisher Policy by using following tag in the app.config/web.config files.

< publisherPolicy apply="no" >

Redirecting Assembly Versions through App.config/Web.config files

Specify information for an assembly by placing information for each assembly inside a element. The element contains information that identifies an assembly. You can have more than one element in the configuration file, but there must be exactly one element in each element. To redirect one version to another, use the element. The oldVersion attribute can specify either a single version, or a range of versions. For example, specifies that the runtime should use version 2.0.0.0 instead of the assembly versions between 1.1.0.0 and 1.2.0.0.

Example:

< 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.0.0.0"/ >
< / dependentAssembly >
< dependentAssembly >
< assemblyIdentity name="mySecondAssembly" publicKeyToken="32ab4ba45e0a69a1" culture="en-us" / >
< !-- Publisher policy can be set only in the application configuration file. -- >
< publisherPolicy apply="no" >
< / dependentAssembly >
< / assemblyBinding >
< / runtime >
< / configuration >

Note: The elements are order-sensitive. You should enter assembly binding redirection information for any .NET Framework version 1.0 assemblies first, followed by assembly binding redirection information for any .NET Framework version 1.1 assemblies

Reference: http://msdn.microsoft.com/en-us/library/7wd6ex19(VS.71).aspx

1 comment:

generic cialis 20mg said...

I, of course, a newcomer to this blog, but the author does not agree