C# – Could not load file or assembly ‘Newtonsoft.Json, Version=7.0.0.0

asp.netasp.net-mvccjson.netnuget

I am facing the error below

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

I could see the below in Web.config

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

So I changed it to

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

In packeges.config I could see the below entry

But still I am facing the same issue. Please help

Best Answer

A lot of things can go wrong and this error message tells you nothing.

But still I am facing the same issue.

Maybe the easiest way will be to try and reinstall the package.

Go to TOOLS > NuGet Package Manager and Select Package Manager Console. Execute the following two commands:

uninstall-package newtonsoft.json -force
install-package newtonsoft.json

If you still get an error after doing this, then what worked for me eventually is that I deleted Json.Net's section from my .config file. Reinstall brings it back if it's not there and apparently you need to delete it. Until there will be a normal solution in the package itself, I'm afraid this manual step is a must. In package manager console again execute:

Update-Package –reinstall Newtonsoft.Json

Also take a look at your .Net version of the projects in your solution.

This is the Microsoft solution with unloading the project.