简体   繁体   English

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

[英]Assembly 'System.Web.Http, ...' uses 'Newtonsoft.Json, Version=6.0.0.0...' which has a higher version than referenced assembly

I'm getting the following error when I Rebuild my project.重建项目时出现以下错误。

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

I have already uninstalled and installed the latest version of Newtonsoft.Json (9.0.1) using Manage NuGet Packages in VS 2013. Why is it still referencing version 6.0.0.0 (or is it 4.5.0.0)?我已经使用 VS 2013 中的管理 NuGet 包卸载并安装了最新版本的 Newtonsoft.Json (9.0.1)。为什么它仍然引用版本 6.0.0.0(或者是 4.5.0.0)?

My web.config shows the following:我的 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>

What else should I do to resolve this?我还应该做些什么来解决这个问题? Thanks.谢谢。

I encountered similar problems with newtonsoft.json reference after installing the nuget package Microsoft.AspNet.WebApi.Owin in combination with Microsoft.Owin.Security.OAuth package. 在将nuget包Microsoft.AspNet.WebApi.Owin与Microsoft.Owin.Security.OAuth包一起安装后,我遇到了与newtonsoft.json引用类似的问题。 I resolved the problem by running the following commands in the nuget package manager 我通过在nuget包管理器中运行以下命令解决了这个问题

First, uninstall the newtonsoft.json 首先,卸载newtonsoft.json

uninstall-package Newtonsoft.Json -Force

Then, install the latest newtonsoft.json 然后,安装最新的newtonsoft.json

install-package Newtonsoft.Json

And finally, update the owin OAuth which seems to be referencing to the old newtonsoft.json version 最后,更新似乎引用旧的newtonsoft.json版本的owin OAuth

update-package Microsoft.Owin.Security.OAuth

After this, build the project and it should compile..At least my did :) 在此之后,构建项目,它应该编译..至少我做了:)

I managed to resolve this by going into web.config and changing this: 我设法通过进入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>

to this: 对此:

<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>

I'm not sure why the "newVersion" should be 9.0.0.0 when my Newtonsoft.Json version is 9.0.1, but it didn't compile with the latter. 我不确定为什么当我的Newtonsoft.Json版本是9.0.1时,“newVersion”应该是9.0.0.0,但它不能用后者编译。

Interestingly, when I later entered the following in the Package Manager Console: 有趣的是,当我稍后在Package Manager控制台中输入以下内容时:

Update-Package Newtonsoft.Json -Version 9.0.1

I could change the "oldVersion" and "newVersion" to anything and it had no effect on the compilation. 我可以将“oldVersion”和“newVersion”改为任何东西,它对编译没有任何影响。

Many thanks to Rajput, Marcus H and Vivek Nuna for your help. 非常感谢Rajput,Marcus H和Vivek Nuna的帮助。

I don't know if you still need this or not. 我不知道你是否还需要这个。 After updating Newton.Json in my project, your kind of error happens. 在我的项目中更新Newton.Json之后,会发生您的错误。 And I found this thread and follow all answer instruction but no luck. 我找到了这个帖子并按照所有答案说明但没有运气。 But when I remove Newton.Json from references , then add my newer version of Newton.Json.dll to references , it works! 但是,当我从引用中删除Newton.Json ,然后将我的新版本的Newton.Json.dll添加到引用时 ,它的工作原理!

remove reference 删除参考

I've just had this issue, and spent way too much time fixing it.我刚遇到这个问题,花了太多时间来修复它。

What clinched it for me was realising that the publish stage of my API didn't publish the web.config in the root folder of the API, but in the bin folder.对我来说最重要的是意识到我的 API 的发布阶段没有在 API 的根文件夹中发布 web.config,而是在 bin 文件夹中。

Moving the web.config to the root fixed the issue as IIS can then set up the API correctly, rather than falling back to host/machine configs (which don't include the rebinding instructions)将 web.config 移动到根目录解决了问题,因为 IIS 可以正确设置 API,而不是回退到主机/机器配置(不包括重新绑定指令)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 程序集&#39;SomeAssembly,使用&#39;System.Web.Mvc,Version = 4.0.0.0,它的版本高于引用的程序集&#39;System.Web.Mvc,Version 3.0.0.0 - Assembly 'SomeAssembly, uses 'System.Web.Mvc, Version=4.0.0.0, which has a higher version than referenced assembly 'System.Web.Mvc, Version 3.0.0.0 无法加载文件或程序集Newtonsoft.json版本6.0.0.0 - Could not load file or assembly Newtonsoft.json Version 6.0.0.0 程序集使用版本X,其版本高于引用的程序集错误 - Assembly uses version X which has a higher version than referenced assembly error <Assembly>使用Microsoft.Synchronization,它具有比引用程序集更高的版本 - <Assembly> uses Microsoft.Synchronization which has a higher version than referenced assembly 程序集XXX具有比引用的程序集XXX高的版本 - Assembly XXX which has a higher version than referenced assembly XXX 具有比参考程序集更高版本的程序集“ XXX” - Assembly 'XXX' which has a higher version than referenced assembly 无法与 Microsoft.AspNet.WebApi.Client 结合加载文件或程序集“Newtonsoft.Json,版本 = 6.0.0.0” - Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0 in combination with Microsoft.AspNet.WebApi.Client 无法在单元测试中加载文件或程序集“Newtonsoft.Json,Version = 6.0.0.0” - Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0 in unit test Microsoft.WindowsAzure.Storage.StorageException 无法加载文件或程序集 &#39;Newtonsoft.Json,版本 = 6.0.0.0, - Microsoft.WindowsAzure.Storage.StorageException Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, 运行时无法加载文件或程序集“Newtonsoft.Json,版本=6.0.0.0 ...”,间接依赖程序集继续寻找旧版本 - Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0 ..." during runtime ,indirect dependency assembly keep looking for old version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM