我在重建项目时收到以下错误。
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
我已经使用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>
我还应该做些什么来解决这个问题?感谢。
答案 0 :(得分:3)
在将nuget包Microsoft.AspNet.WebApi.Owin与Microsoft.Owin.Security.OAuth包一起安装后,我遇到了与newtonsoft.json引用类似的问题。 我通过在nuget包管理器
中运行以下命令解决了这个问题首先,卸载newtonsoft.json
uninstall-package Newtonsoft.Json -Force
然后,安装最新的newtonsoft.json
install-package Newtonsoft.Json
最后,更新似乎引用旧的newtonsoft.json版本的owin OAuth
update-package Microsoft.Owin.Security.OAuth
在此之后,构建项目,它应该编译..至少我做了:))
答案 1 :(得分:2)
我设法通过进入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>
到此:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
我不确定为什么&#34; newVersion&#34;当我的Newtonsoft.Json版本是9.0.1时应该是9.0.0.0,但它没有用后者编译。
有趣的是,当我稍后在软件包管理器控制台中输入以下内容时:
Update-Package Newtonsoft.Json -Version 9.0.1
我可以改变&#34; oldVersion&#34;和&#34; newVersion&#34;任何东西,它对编译没有影响。
非常感谢Rajput,Marcus H和Vivek Nuna的帮助。
答案 2 :(得分:0)
我不知道您是否仍然需要这个。 在我的项目中更新Newton.Json之后,您会发生这种错误。我找到了这个线程,并按照所有答案的指示进行操作,但是没有运气。 但是,当我从引用中删除Newton.Json ,然后将我的较新版本的Newton.Json.dll添加到引用时,它就可以了!