在新的ASP.NET MVC 5项目中更新NuGet软件包引用后,如何解决与JSON.NET的汇编版本冲突?(How can I fix assembly version conflicts with

编程入门 行业动态 更新时间:2024-10-26 03:38:04
在新的ASP.NET MVC 5项目中更新NuGet软件包引用后,如何解决与JSON.NET的汇编版本冲突?(How can I fix assembly version conflicts with JSON.NET after updating NuGet package references in a new ASP.NET MVC 5 project?)

我在VS 2013(Update 1)中创建了一个新的ASP.NET MVC 5 Web项目,然后更新了所有NuGet软件包。 当我构建项目时,我会收到以下警告:

警告MSB3243:无法解决“Newtonsoft.Json,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed”和“Newtonsoft.Json,Version = 4.5.0.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed”之间的冲突。

当我检查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 created a new ASP.NET MVC 5 web project in VS 2013 (Update 1) then updated all NuGet packages. When I build the project, I get the following warning:

warning MSB3243: No way to resolve conflict between "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed".

When I check the web.config, however, I see that a binding redirect is in place:

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

Which is exactly what the warning advises.

How can I fix this warning?

最满意答案

这里我用来修复警告的步骤:

在VS中卸载项目 编辑.csproj文件 搜索对Newtonsoft.Json程序集的所有引用 找到两个,一个到v6,一个到v5 用V6替换对v5的引用 重新加载项目 构建并注意装配参考故障 查看引用,看看现在有两个到Newtonsoft.Json。 删除那些无法解决的问题。 重建 - 没有警告

Here the steps I used to fix the warning:

Unload project in VS Edit .csproj file Search for all references to Newtonsoft.Json assembly Found two, one to v6 and one to v5 Replace the reference to v5 with v6 Reload project Build and notice assembly reference failure View References and see that there are now two to Newtonsoft.Json. Remove the one that's failing to resolve. Rebuild - no warnings

更多推荐

Newtonsoft,web,Json,电脑培训,计算机培训,IT培训"/> <meta name="descripti

本文发布于:2023-07-26 19:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1279936.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:软件包   如何解决   冲突   版本   项目

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!