Assembly redirects fix

If you ever run into a problem when after updating the library through nuget compilation throws an error of assembly version not found as system is still expecting an older version. This may cause due to the assembly redirects in the code.
One way to fix this is to run the following command in the Package Manager Console

PM> Get-Project –All | Add-BindingRedirect

Second method to fix this issue is to enable the automatic binding redirects in the web apps project.

Automatic 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’re always prompted to add binding redirects, you don’t need to explicitly disable this feature for a web app.

To add binding redirects to a web.config file:

  • In Visual Studio, compile the app, and check for build warnings.
    clr-assemblyrefwarning
  • If there are assembly binding conflicts, a warning appears. Double-click the warning, or 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.

    clr-addbindingredirect

Leave a comment