簡體   English   中英

在 Ubuntu 上為 .NET 安裝 newtonsoft-json

[英]Install newtonsoft-json for .NET on Ubuntu

我只是想解析一些 JSON,我從 C# 的 API 調用中返回。我在 Ubuntu 上使用 .NET。為此,我嘗試使用安裝 newtonsoft-json

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 字符串。還有其他想法嗎?

我終於想通了! 我只需要手動更改package.json文件,然后鍵入dotnet restore 在那之后,newtonsoft-json工作得很好。

在終端上運行此命令(這是OpenSUSE控制台/終端。但是,相同的概念適用於Ubuntu。)

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

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

這應該解決它。

此dll在Mono gac中可用。 您需要添加新的引用,否則會收到錯誤消息。 如果您使用的是corefx,請使用dotnet restore。 包將被加載。 檢查鏈接

這對我有用:

sudo apt-get install Newtonsoft.Json

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM