Today we started getting an error from three web applications. Two were web services and one was an ASP.NET MVC website. The error was:
Could not load file or assembly ‘System.Net.Http, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The error was occurring on this standard line in the global.asax file:
Looking at the trace statements on the error page, there was a mention of a binding redirect, which I recall seeing in the web.config of the site. That section in the web config looked like:
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-18.104.22.168" newVersion="22.214.171.124"/>
This config block had been in place since December, 2015. The block seems to have been added by a NuGet package at the same time, possibly with a Framework version upgrade.
However it originally ended up there, removing the config block allowed the sites to launch again. It’s unknown why this started happening after a Visual Studio upgrade.