4 stars based on
You can redirect compile-time binding references to. NET Framework assemblies, third-party assemblies, or your own forwarding and bindings assemblies. You can redirect your app to use a different version of an assembly in a number of ways: This article discusses how assembly binding works in the.
NET Framework and how it can be configured. NET Framework assemblies are sometimes redirected through a process called assembly unification. Forwarding and bindings Framework consists of a version of the common language runtime and about two dozen. NET Framework assemblies that make up the type library. NET Framework assemblies are treated by the runtime as a single unit. By default, forwarding and bindings an app is launched, all references to types in code run by the runtime are directed to.
NET Framework assemblies that have the same version number as the runtime that is loaded in a process. The redirections that occur with this model are the default behavior for the runtime.
For example, if your app references types in the System. XML namespace and was built by using the. XML assembly that ships with runtime version 4. If you want to redirect the binding reference to point to the System. XML assembly that ship with the. NET Framework 4, you can put forwarding and bindings information in the app configuration file. A binding redirection in a configuration file for a unified.
NET Framework assembly cancels the unification for that assembly. In addition, you may want to manually redirect assembly binding for third-party assemblies if there are multiple versions available. Vendors of assemblies can direct apps to a newer version of an assembly by including a publisher policy file with the forwarding and bindings assembly.
The publisher policy file, which is located in the global assembly cache, contains assembly redirection settings. For example, redirections from version 2. However, a redirection from version 3.
Each major version of the. NET Framework has its own forwarding and bindings policy file. If a publisher policy file exists for an assembly, the runtime checks this file after checking the assembly's manifest and app configuration file. Vendors should use publisher policy files only when the new assembly is backward compatible with the assembly being redirected. You can bypass publisher policy for your app by specifying settings in the app configuration forwarding and bindings, as discussed in the Bypassing publisher policy section.
Forwarding and bindings are a few different techniques for changing the binding behavior for your app through the app configuration file: You can manually edit the app configuration file to resolve assembly issues.
For example, if a vendor might release a newer version of an assembly that your app uses forwarding and bindings supplying a publisher policy, because they do not guarantee backward compatibility, you can direct your app to use the newer version of the assembly by putting assembly binding information in your app's configuration file as follows.
Starting with Forwarding and bindings Studionew desktop apps that target the. This means that if two components reference different versions of the same strong-named assembly, the runtime automatically adds a binding redirection to the newer version of the assembly in the output app configuration app. This redirection overrides the assembly unification that might otherwise take place. For example, let's say that your app directly references an out-of-band.
NET Framework component but uses a third-party library that targets an older version of the same component. When you compile the app, the output app configuration forwarding and bindings is forwarding and bindings to contain a binding redirection to the newer version of the component. If you create a web app, you receive a build warning regarding the binding conflict, which in turn, gives you the option to add the necessary binding redirect to forwarding and bindings source web configuration file.
If you manually add binding redirects to the source app. For example, let's say you insert the following binding redirect for an assembly:. If another project in your app references version 1. You can enable automatic binding redirection if your app targets older versions of the. You can override this default behavior by providing binding redirection information in the app. For information about how to turn this feature on or off, see How to: Enable and Disable Automatic Binding Redirection.
You can override publisher policy in the app configuration file if necessary. For example, new versions of assemblies that claim to be backward compatible can still break an app. Bypass publisher policy to keep your app running for your users, but make sure you report the problem to the forwarding and bindings vendor. If an assembly has a publisher policy file, the vendor should make sure that the assembly is backward compatible and that clients can use the new version as much as possible.
There might be rare cases when a machine administrator wants all apps on a computer to use a specific version of an assembly. For example, the administrator might want every app to use a particular assembly version, because that version fixes a security hole. If an assembly is redirected in the machine's configuration file, all apps on that machine that use the old version will be directed to use the new version.
The machine configuration file overrides the app configuration file and the publisher policy file. The oldVersion attribute can specify a single assembly version or a range of versions.
The newVersion attribute should specify a single version. The following code example demonstrates a variety of binding redirect scenarios. The example specifies a redirect for a range of versions for myAssemblyand a single binding redirect for mySecondAssembly. The example also specifies that publisher policy file will not override the binding redirects for myThirdAssembly. To bind an assembly, you forwarding and bindings specify the string "urn: This optional attribute uses a.
Forwarding and bindings Framework version number to indicate what version it applies to. For example, to redirect assembly forwarding and bindings for a. You should enter redirection information in version order.
For example, enter assembly binding redirection information for. 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. If there is 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 4 assembly, use the pattern shown in the following pseudocode. Create a Forwarding and bindings Policy. The feedback system for this content will be changing soon. Old comments will not be carried over. If content within a comment thread is important to you, please forwarding and bindings a copy. Forwarding and bindings more information on the upcoming change, we invite you to read our blog post. Assembly unification and default binding Bindings to.
Redirecting assembly versions by using publisher policy Vendors of assemblies can direct apps to a newer version of an assembly by including a publisher policy file with the new assembly. Redirecting assembly versions at the app level There are a few different techniques for changing the binding behavior for your app through the app configuration file: Manually editing the app config file You can manually edit the app configuration file to resolve assembly issues.
For example, let's say you insert the following binding redirect for an assembly: Bypassing publisher policy You can override publisher policy in the app configuration file if necessary. Redirecting assembly versions at the machine level There might be rare cases when forwarding and bindings machine administrator wants all apps on a computer to use a specific version of an assembly.
NET Framework version 3. NET Framework version 4. Create a Publisher Policy Note The feedback system for this content will be changing soon.