Scott L
Scott L

Reputation: 667

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

Upvotes: 0

Views: 924

Answers (2)

Scott L
Scott L

Reputation: 667

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

Upvotes: 0

Joey Cai
Joey Cai

Reputation: 20067

The fix for this should be fairly easy: in your web.config find the compilation\assemblies section and add the System.Web.Http assembly there under System.Net.Http:

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

Another thing that might help, if you get errors compiling your code, try referencing System.Web.Http version 4.2 and setting the build action to copy local.

For more details, you could refer to this article.

Upvotes: 1

Related Questions