在Ubuntu上安装newtonsoft-json for .NET

时间:2021-05-20 23:39:10

I'm simply trying to parse some JSON that I'm getting back from an API call in C#. I'm using .NET on Ubuntu. To accomplish this, I've tried to install newtonsoft-json using

我只是试图解析一些我从C#中的API调用回来的JSON。我在Ubuntu上使用.NET。为此,我尝试使用安装newtonsoft-json

nuget install Newtonsoft.Json

The library installs successfully. Yet when I run the program, I get the following error:

库安装成功。然而,当我运行该程序时,我收到以下错误:

error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

What is going on here? How do I get .NET to recognize the new library?

这里发生了什么?如何让.NET识别新库?

Also, I'm not particularly attached to this library, I just want to parse a frikin JSON string in .NET on Ubuntu. Any other ideas?

另外,我并不特别喜欢这个库,我只是想在Ubuntu上解析.NET中的frikin JSON字符串。还有其他想法吗?

3 个解决方案

#1


0  

I finally figured it out! I just had to manually alter my package.json file and then type dotnet restore. After that, newtonsoft-json worked just fine.

我终于想通了!我只需手动更改我的package.json文件,然后键入dotnet restore。在那之后,newtonsoft-json工作得很好。

#2


0  

Run this command on terminal (This is OpenSUSE console/terminal. However, same concept apply for Ubuntu.).

在终端上运行此命令(这是OpenSUSE控制台/终端。但是,同样的概念适用于Ubuntu。)。

xxxx@localhost:~/Path/To/Project>dotnet add package Newtonsoft.Json

Than

xxxx@localhost:~/Path/To/Project>dotnet restore

This should resolve it.

这应该解决它。

#3


-1  

This dll is available in Mono gac. you need to add a new reference or you get the error message. if you're using corefx then use dotnet restore. the package will be loaded. check the link

这个DLL可以在Mono gac中使用。您需要添加新的引用,否则您将收到错误消息。如果您使用的是corefx,请使用dotnet restore。包将被加载。检查链接

#1


0  

I finally figured it out! I just had to manually alter my package.json file and then type dotnet restore. After that, newtonsoft-json worked just fine.

我终于想通了!我只需手动更改我的package.json文件,然后键入dotnet restore。在那之后,newtonsoft-json工作得很好。

#2


0  

Run this command on terminal (This is OpenSUSE console/terminal. However, same concept apply for Ubuntu.).

在终端上运行此命令(这是OpenSUSE控制台/终端。但是,同样的概念适用于Ubuntu。)。

xxxx@localhost:~/Path/To/Project>dotnet add package Newtonsoft.Json

Than

xxxx@localhost:~/Path/To/Project>dotnet restore

This should resolve it.

这应该解决它。

#3


-1  

This dll is available in Mono gac. you need to add a new reference or you get the error message. if you're using corefx then use dotnet restore. the package will be loaded. check the link

这个DLL可以在Mono gac中使用。您需要添加新的引用,否则您将收到错误消息。如果您使用的是corefx,请使用dotnet restore。包将被加载。检查链接