Failed to load file or assembly "Newtonsoft.Json" or one of its dependencies

Firstly, this is not just a duplicate. None of the answers to the following questions work for me.

http://goo.gl/tS40cn
http://goo.gl/pH6v2T

I just updated all my packages using Nuget Package Manager and I started getting this error.

Failed to load file or assembly "Newtonsoft.Json, Version = 6.0.0.0, Culture = neutral, PublicKeyToken = 30ad4fe6b2a6aeed" or one of its dependencies. The located assembly manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

My Package Config has:

<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> 

Web.config includes this piece of code:

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

Link Properties for Newtonsoft.Json

enter image description here

According to answers to similar questions, I tried the following:

  • Reinstalling a package using Update-Package –reinstall Newtonsoft.Json
  • Removing dependentAssembly config from Web.config for Newtonsoft.Json
  • Changing newVersion to 6.0.0.0 and 7.0.0.0 in dependentAssembly . This led to a new error.
  • Also tried Get-Project -All | Add-BindingRedirect Get-Project -All | Add-BindingRedirect . It changes newVersion to Newtonsoft.Json to 4.5.0.0 . But the problem remains unresolved.

Please help me fix this.

+6
source share
9 answers

I know this is old, but I ran into the same problem. My problem was that several projects in the solution used Newtonsoft.Json, but some of them were in different versions. I updated them all to the last (9.0.1 type I), and the problem disappeared.

In any case ... if someone is still dealing with this, be sure to update the package in the EVERY project in the solution.

NTN

+6
source

Add a Newtonsoft link in my MVC project solves the problem for me.

+1
source

After completing most of the above (and some other messages), I deleted with the package manager all of the following from the affected project:

 Microsoft.AspNet.WebApi Microsoft.AspNet.Client Microsoft.AspNet.Core Microsoft.AspNet.WebHost Newtonsoft.Json 

Then reinstalled Microsoft.AspNet.WebApi, which automatically installed .Client, .Core, .WebHost, .Json.

+1
source

run this command in the package manager console:

 PM> Install-Package Newtonsoft.Json -Version 6.0.1 
0
source
  • In your VS solutions browser, remove the Newtonsoft.Json link.
  • Download the 6.0 binaries in Newtonsoft binaries here
  • Extract files
  • Add the Newtonsoft library manually. In Visual Studio, right-click the link and select Add Link
  • Click Browse
  • Browse to the extracted files under Net45 and select Newtonsoft.Json.dll
  • If it does not work, try using Net40 instead, after going through the whole procedure again.
0
source

Run Update-Package Newtonsoft.Json -Reinstall

It should remove the link to your version 4.5 and reinstall the new version specified in your package.config. It will also update the binding redirection, which should be as follows:

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

Since you already said in your question that you have already tried this, you can first try deleting the existing link manually. You may also want to make sure that the files are not read-only on disk or otherwise locked using the source control.

0
source

In my case, the following code was present in my local debug version of the solution, but not in my version of the code on the server. Adding code to my server. The Web.config file fixed the problem.

 <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" /> <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> </dependentAssembly> </assemblyBinding> 

0
source

I had this error myself, and at first it used Update-Package –reinstall Newtonsoft.Json -IncludePrerelease , it did not work, then Install-Package Newtonsoft.Json . he worked.

0
source

Change the configuration as follows:

0
source

All Articles