How to: Enable and Disable Automatic Binding Redirection | Microsoft Docs

How to: Enable and Disable Automatic Binding Redirection2017-3-30 2 min to read Contributors Starting with Visual Studio 2013, when you compile apps that target the .NET Framework 4.5.1, binding redirects may be automatically added to the app configuration file to override assembly unification. Binding redirects are added if your app or its components reference more than one version of the same assembly, even if you manually specify binding redirects in the configuration file for your app. The automatic binding redirection feature affects traditional desktop apps and web apps that target the .NET Framework 4.5.1, although the behavior is slightly different for a web app. You can enable automatic binding redirection if you have existing apps that target previous versions of the .NET Framework, or you can disable this feature if you want to keep manually authored binding redirects.Disabling automatic binding redirects in desktop appsAutomatic binding redirects are enabled by default for traditional desktop apps that target the .NET Framework 4.5.1 and later versions. The binding redirects are added to the output configuration (app.config) file when the app is compiled and overrides the assembly unification that might otherwise take place. The source app.config file is not modified. You can disable this feature by modifying the project file for the app.To disable automatic binding redirectsIn Visual Studio, select the project in Solution Explorer, and then choose Open Folder in File Explorer from the shortcut menu.In File Explorer, find the project (.csproj or .vbproj) file, and open it in Notepad.In the project file, find the following property entry:trueChange true to false:falseEnabling automatic binding redirects manuallyYou can enable automatic binding redirects in existing apps that target older versions of the .NET Framework, or in cases where you are not automatically prompted to add a redirect. If you are targeting a newer version of the framework but do not get automatically prompted to add a redirect, you will likely get build output that suggests you remap assemblies.To manually add an automatic binding redirect propertyIn Visual Studio, select the project in Solution Explorer, and then choose Open Folder in File Explorer from the shortcut menu.In File Explorer, find the project (.csproj or .vbproj) file, and open it in Notepad.Add the following element to the first configuration property group (under the tag):trueThe following shows an example project file with the element inserted.XMLCopy Debug AnyCPU {123334} … true … Compile your app.Enabling automatic binding redirects in web appsAutomatic binding redirects are implemented differently for web apps. Because the source configuration (web.config) file must be modified for web apps, binding redirects are not automatically added to the configuration file. However, Visual Studio notifies you of binding conflicts, and you can add binding redirects to resolve the conflicts. Because you are always prompted to add binding redirects, you do not need to explicitly disable this feature for a web app.To add binding redirects to a web.config fileIn Visual Studio, compile the app, and check for build warnings.If there are assembly binding conflicts, a warning appears. Double-click the warning. (Keyboard: Select the warning and press Enter.)A dialog box that enables you to automatically add the necessary binding redirects to the source web.config file appears.

Source: How to: Enable and Disable Automatic Binding Redirection | Microsoft Docs

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s