Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JsonConvert同时存在于Newtonsoft和System.Net.Http.Visual Studio 2017 for Mac中_Json_Macos_Msbuild_Visual Studio 2017 - Fatal编程技术网

JsonConvert同时存在于Newtonsoft和System.Net.Http.Visual Studio 2017 for Mac中

JsonConvert同时存在于Newtonsoft和System.Net.Http.Visual Studio 2017 for Mac中,json,macos,msbuild,visual-studio-2017,Json,Macos,Msbuild,Visual Studio 2017,我有一个项目一直在使用Xamarin的MonoDevelop 我一直在使用Newtonsoft的Json nuget包 我刚刚为Mac下载了Visual Studio 2017 我尝试在VS2017Mac中构建我的项目,但出现以下错误: error CS0433: The type 'JsonConvert' exists in both 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6

我有一个项目一直在使用Xamarin的MonoDevelop

我一直在使用Newtonsoft的Json nuget包

我刚刚为Mac下载了Visual Studio 2017

我尝试在VS2017Mac中构建我的项目,但出现以下错误:

error CS0433: The type 'JsonConvert' exists in both 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' and 'System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
我想我应该可以通过添加Newtonsoft.Json来解决这个问题。到JsonConvert的前面,但这不起作用

如果可能的话,我不想删除Newtonsoft的实现,因为我认为他们的库还有更多的功能。还有别的办法解决这个问题吗?为什么不添加完整的汇编参考工作

  • 在项目Newtonsoft.Json引用的属性窗口中,将别名的值从
    global
    更改为
    global,foo

  • 插入
    外部别名foo
    作为使用Newtonsoft.Json的任何类的第一行

  • 使用
    foo.
    限定成员资格。示例:
    foo.Newtonsoft.Json.JsonConvert.SerializeObject(someObject)}


  • 安装newtonsoft.json包的上一版本。

    我收到以下错误消息,但在C#中有另一个库(Ranet):

    错误CS0433类型“JsonConvert”在两个数据库中都存在 'Microsoft.AnalysisServices.Tabular.Json,版本=14.0.0.0, 文化=中性,PublicKeyToken=89845dcd8080cc91'和 'Newtonsoft.Json,版本=11.0.0.0,区域性=中性, PublicKeyToken=30AD4FE6B2A6EED'

    我用别名解决了这个问题,但我想提供更多的细节,因为我很难使用这些答案和说明来实现。我就是这样做的:

  • 在解决方案资源管理器中,右键单击“Newtonsoft.json”,将“Newton”添加到别名字段中,它应该如下所示:
  • 将以下代码添加到文件的第一行(在使用所有语句之前):
  • extern别名Newton;
    
  • 在using语句末尾添加以下引用:
  • 使用NewtonReference=Newton::Newtonsoft.Json;
    
  • 现在,您可以使用以下代码调用Newtonsoft方法:
  • NewtonReference.JsonConvert.DeserializeObject(“”);
    
  • 最后一个示例如下所示:
  • extern别名Newton;
    使用制度;
    使用NewtonReference=Newton::Newtonsoft.Json;
    公共类测试{
    公共静态列表TestMethod(){
    NewtonReference.JsonConvert.DeserializeObject(“”);
    }  
    }
    

    希望这会对其他人有所帮助:)

    如果有人还在寻找解决方案,我去了项目参考,它展示了Newtonsoft的两个不同版本(我的版本是12.0.0和6.0.0)。我点击了旧版本,它显示了文件的存储路径。我只是去那里把它删除了。完成后,我在9.0.0版本中遇到了同样的问题,并且做了同样的事情。当我再次打开它时,问题已经解决了

    对于
    JsonIgnore
    属性,我也得到了同样的结果。