C# 在Ubuntu上安装newtonsoft json for.NET
我只是想解析一些JSON,这些JSON是我从C#中的API调用中得到的。我在Ubuntu上使用.NET。为了实现这一点,我尝试使用C# 在Ubuntu上安装newtonsoft json for.NET,c#,.net,linux,ubuntu-16.04,C#,.net,Linux,Ubuntu 16.04,我只是想解析一些JSON,这些JSON是我从C#中的API调用中得到的。我在Ubuntu上使用.NET。为了实现这一点,我尝试使用 nuget install Newtonsoft.Json 库安装成功。然而,当我运行程序时,我得到以下错误: error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly refe
nuget install Newtonsoft.Json
库安装成功。然而,当我运行程序时,我得到以下错误:
error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
这是怎么回事?如何让.NET识别新图书馆
另外,我并不特别喜欢这个库,我只想在Ubuntu上解析.NET中的frikin JSON字符串。还有其他想法吗?此dll在Mono gac中提供。您需要添加新的引用,否则会收到错误消息。如果您使用的是corefx,则使用dotnet restore。将加载该包。
我终于明白了!我只需手动修改package.json文件,然后键入
dotnetrestore
。在那之后,newtonsoft json工作得很好。在终端上运行这个命令(这是OpenSUSE控制台/终端。然而,同样的概念也适用于Ubuntu)
这应该可以解决问题。您能解释一下吗?我在.NET核心类库解决方案中没有看到package.json文件。如果我在VS的命令提示符下键入“dotnet restore”,我也不知道应该在哪里键入它。它告诉我:命令“dotnet”无效。谢谢
xxxx@localhost:~/Path/To/Project>dotnet add package Newtonsoft.Json
xxxx@localhost:~/Path/To/Project>dotnet restore