简体   繁体   中英

Newtonsoft.Json FileLoadException

This error is driving me crazy!!

Here is the error message:

[FileLoadException: Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

I have a WebApi and a Web project both using .NET Framework 4.5.1 . My application builds successfully but when I run the Web app I get the error message above. I have tried many things I have found on Google & Stackoverflow in regards to this error but no success.

packages.config - <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net451" />

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

I have tried removing the Newtonsoft.Json.dll and re-adding it but I still get the same error.

I would appreciate all help in trying to resolve this issue.

Newtonsoft.Json is included in the packages.config as part of the default MVC/WebAPI project.

The package is also included in the packages directory but for some reason NuGet package manager doesn't seem to know that it is installed.

I fixed this problem by:

  1. Right Click Solution. Select "Manage NuGet Packages for Solution".
  2. Select "Installed" on the left and check if Json.NET is already installed (in my case it wasn't).
  3. If Json.NET is installed, see if there is an update and apply it.
  4. If Json.Net is NOT installed, select "Online" on the left and search for "Newtonsoft.Json" in the upper right.
  5. Package name will read Json.Net. Select the Install button and let it do its work. It will modify web.config and packages.config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM