Binding redirect updates for Aptify 6.2 config files

A common error after upgrading an application bin directory is around binding redirects. The following binding redirects are needed for all applications that are being updated. If a previous binding redirect exists in the config file, it must be replaced with this entry. If you have two binding redirects for the same assembly in the same file, .NET does not guarantee which one will be applied.  

You may see binding redirect entries in your configuration file that are not listed here. That's ok. This page only lists redirects that need updating in the Aptify 6.2 release.

Newtonsoft.Json.dll

<dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>

The following binding redirects are necessary in the web.config for any http based applications (Aptify Web services, e-Business 6 services and classic e-Business).  It is rare that they will be needed in other applications.  However if you see them in your existing config file you should update them.

System.Web.Mvc.dll

<dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>


System.Web.Http.dll

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="5.2.3.0"/>
</dependentAssembly>


System.Net.Http.Formatting.dll

<dependentAssembly>
    <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="5.2.3.0"/>
</dependentAssembly>


System.Web.Cors.dll

<dependentAssembly>
    <assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.2.3.0"/>
</dependentAssembly>


Microsoft.Owin.dll

<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>

Microsoft.Owin.Security.dll
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0"/>
</dependentAssembly>

Microsoft.AspNet.SignalR.Core.dll
<dependentAssembly>
<assemblyIdentity name="Microsoft.AspNet.SignalR.Core" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.4.1.0" newVersion="2.4.1.0"/>
</dependentAssembly>


Microsoft.AspNet.SignalR.SystemWeb.dll
<dependentAssembly>
<assemblyIdentity name="Microsoft.AspNet.SignalR.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.4.1.0" newVersion="2.4.1.0"/>
</dependentAssembly>

What are binding redirect errors?

Binding redirects are a way to update an assembly at run time without recompiling the assemblies that depend on it. When the assembly changes in the bin directory and a redirect is not applied to the config file an error typically occurs at runtime.  

Aptify tries to account for these in the general upgrade notes, but depending on your configurations you may be targeting assemblies we are not accounting for. The error will state that it's unable to load the assembly in question.  An example error is shown below:

This error has the information required to troubleshoot the problem. It shows us the assembly that's having the problem is Newtonsoft.Json.dll.  Something is trying to load version 6 and version 9 of this assembly.  The first thing to do is look at what versions is in the bin directory by right clicking on the assembly, opening the properties and clicking on the details tab.  

This shows the assembly in the bin directory as version 10. Other assemblies compiled against other versions of Newtonsoft.Json.dll need to be redirected to the version in the bin directory.  Aptify has placed the version we require in the bin directory, and the general upgrade instructions should inform you of the correct binding redirect to add to the configuration file.  However, you may have custom code depending on other versions of the same assembly. You must make a determination if the version in the bin directory will work for your needs. If it will then adjust the binding redirect entry so the version you are compiling against is redirected to the new version.  For example:

<dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>

The above entry redirects anyone looking for versions 0 through 9 to version 10.  Version 10 is what's in the bin directory.  

If your application needs a version different from Aptify's, the impact will depend on the library in question and what types of breaking changes they make through versions. In general, you should be able to use a newer version than what Aptify is shipping with provided you test.