Search code examples
c#.netazureumbraco

Azure failing Could not load file or assembly 'System.Net.Http, Version=4.2.0.0


I have been getting this error for a while now.

enter image description here

Oddly I only get this error when I publish the app to to Azure, locally it's fine.

I've tired changing the redirect to:

 <dependentAssembly>
  <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.1.1.0" />
</dependentAssembly>

I've looked online and so fair no luck.

The app it's self is a Umbraco site using framework 4.7.2

Any help would be great!

UPDATE - I put System.Net.Http as a reference to my web project and set the copy local to true, this means the DLL was published but now I'm getting the error:

enter image description here

I've tried to add the following:

 <add assembly="System.Web.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

And I've also tried this:

 <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
  </dependentAssembly>

Hope that helps


Solution

  • I managed to fix this by removing all references to System.Http.Net, uninstalling it from NuGet, deleting the DLL form ( (c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib)

    Then I installed it again via NuGet but the latest version and removed all the additional binding redirects from the web.config.

    This then fixed the issue.

    Thanks