How to resolve this conflict of two JSON.net existing?

送分小仙女□ 提交于 2019-12-08 16:21:21

问题


I updated json.net in all projects in my solution and after I get this error:

The type 'Newtonsoft.Json.JsonConvert' exists in both '\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll' and 'c:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll

Why is it trying to load json.net from the Blend folder and how do I get around this issue?

Thanks.


回答1:


In my case, the problem was that there were two references to two different versions of Newtonsoft.Json.dll in my project. This wasn't apparent by looking at the references in the Solution tree view: you have to examine the csproj file.

To fix this:

  1. right-click the project in Visual Studio, and select Unload Project
  2. search the MSBuild file for references to Newtonsoft.Json
  3. delete the reference the older version of the library
  4. right-click the project and reload it.



回答2:


In my case, I just used the fully qualified name of the assembly:

var obj = Newtonsoft.Json.JsonConvert...

(VS Community 2017 version 15.7.5)




回答3:


In my case I have a duplicated but it was saying version 6 on the error on the project after unloading it and removing all duplicates but the latest solved the problem when I reload it.

Thank you



来源:https://stackoverflow.com/questions/21637424/how-to-resolve-this-conflict-of-two-json-net-existing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!