程序集“System.Web.Http, ...”使用“Newtonsoft.Json, Version=6.0.0.0...”,它的版本高于引用的程序集

Win*_*oek 5 c# asp.net json.net

重建项目时出现以下错误。

Assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' which has a higher version than referenced assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'    D:\Development\MyProject\bin\System.Web.Http.dll
Run Code Online (Sandbox Code Playgroud)

我已经在 VS 2013 中使用 Manage NuGet Packages 卸载并安装了最新版本的 Newtonsoft.Json (9.0.1)。为什么它仍然引用版本 6.0.0.0(或者是 4.5.0.0)?

我的 web.config 显示以下内容:

<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>
Run Code Online (Sandbox Code Playgroud)

我还应该做些什么来解决这个问题?谢谢。

Mar*_*und 6

我在安装 nuget 包 Microsoft.AspNet.WebApi.Owin 和 Microsoft.Owin.Security.OAuth 包后,遇到了类似 newtonsoft.json 引用的问题。我通过在 nuget 包管理器中运行以下命令解决了这个问题

首先,卸载newtonsoft.json

uninstall-package Newtonsoft.Json -Force
Run Code Online (Sandbox Code Playgroud)

然后,安装最新的newtonsoft.json

install-package Newtonsoft.Json
Run Code Online (Sandbox Code Playgroud)

最后,更新似乎引用旧 newtonsoft.json 版本的 owin OAuth

update-package Microsoft.Owin.Security.OAuth
Run Code Online (Sandbox Code Playgroud)

在此之后,构建项目,它应该编译..至少我做到了:)