Configuring Assembly Binding Redirection

By default, applications use the set of .NET Framework assemblies that shipped with the runtime version used to compile the application. You can use the appliesTo attribute on the <assemblyBinding> element in an application configuration file to redirect assembly binding references to a specific version of the .NET Framework assemblies. This optional attribute uses a .NET Framework version number to indicate which version it applies to. If no appliesTo attribute is specified, the <assemblyBinding> element applies to all versions of the .NET Framework.

The appliesTo attribute was introduced in the .NET Framework version 1.1; it is ignored by the .NET Framework version 1.0. This means that all <assemblyBinding> elements are applied when using the .NET Framework version 1.0, even if an appliesTo attribute is specified.

Note Note

Use the appliesTo attribute to limit assembly binding redirection to a specific version of the runtime.

For example, to redirect assembly binding for a .NET Framework version 1.0 assembly, you would include the following XML code in your application configuration file.

<runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v1.0.3705">
            <dependentAssembly> 
               * assembly information goes here *
            </dependentAssembly>
       </assemblyBinding>
</runtime>

The <assemblyBinding> 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. Finally, enter assembly binding redirection information for any .NET Framework assembly redirection that does not use the appliesTo attribute and therefore applies to all versions of the .NET Framework. In case of a conflict in redirection, the first matching redirection statement in the configuration file is used.

For example, to redirect one reference to a .NET Framework version 1.0 assembly and another reference to a .NET Framework version 1.1 assembly, you would use the pattern shown in the following pseudocode.

<assemblyBinding xmlns="..." appliesTo="v1.0.3705"> 
<! — .NET Framework version 1.0 redirects here. --> 
</assemblyBinding> 

<assemblyBinding xmlns="..." appliesTo="v1.1.4322"> 
    <! — .NET Framework version 1.1 redirects here. --> 
</assemblyBinding> 

<assemblyBinding xmlns="..."> 
<!-- Redirects meant for all versions of the .NET Framework. --> 
</assemblyBinding>

The runtime parses configuration files once when an application domain is created, and loads code into that application domain. The common language runtime handles errors in a configuration file by ignoring the entry. The runtime ignores the entire configuration file if it contains malformed XML. For invalid XML, only the invalid sections are ignored.

You can determine whether a configuration file is being used by determining whether assembly binding redirects are occurring. Use the Assembly Binding Log Viewer (Fuslogvw.exe) to see which assemblies are being loaded. To see all assembly binds, you must set an entry for ForceLog in the registry.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft