我从http://www.newtonsoft.com/json下载了Newtonsoft.Json代码,并在VS 2013中打开了Newtonsoft.Json.Net20.sln。构建它时,我遇到了很多错误,所有错误都在JsonPrimitiveContract.cs中,这是一个示例
Invalid expression term '[' C:\Users\<path removed>\Newtonsoft.Json-master\Src\Newtonsoft.Json\Serialization\JsonPrimitiveContract.cs 60 13 Newtonsoft.Json.Net20
我也尝试编译Newtonsoft.Json.sln,同样的错误。显然我缺少了什么,只是不知道什么?
最佳答案
Json.NET具有solution .Net 2.0版的targets,但是源代码必须使用C#6.0编译器进行编译。从Issue #802:
06needhamt commented 6 days ago
I am requesting a branch of JSON.NET that can be compiled without c#6 as my organization does not support C# 6 and need to use a source distribution due to modifications,
JamesNK commented 6 days ago
Nope. C# 6 or bust.
Or use the source before C# 6 features.
根据您的问题,您正在使用VS2013。因此,您需要转到VS 2015或尝试将C#6.0安装到VS2013。尽管我从未尝试过,但How to enable C# 6.0 feature in Visual Studio 2013?表示有可能,并解释了如何做。
关于c# - 无法编译Newtonsoft.Json.Net20,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35143431/