c# - JSON.Net 在构建时抛出异常

标签 c# windows-phone-7 json.net

我正在使用 WebClient.DownloadStringAsync() 下载 JSON 字符串,并使用 Json.Net 的 JObject.Parse() 将该字符串解析为 JSON 对象,所以我可以使用 LINQ 查询该对象。但是当我尝试构建解决方案时,它会抛出异常和警告

Reference to type 'System.Func`2' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\mscorlib.dll', but it could not be found

使用这些包:

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Newtonsoft.Json; //v 6.0.3
using Newtonsoft.Json.Linq;
using System.Runtime.Serialization;

最佳答案

查看其他 SO 答案:how to properly install Json.net via nuget for windows phone 7.1 and Silverlight v.4,0

由于您的目标是 WP8 之前的 Windows Phone 版本,因此您应该使用旧版本的 Newtonsoft.Json。

您可以执行 Install-package Newtonsoft.Json -version 5.0.8 以获得 5.0.8 版本,但删除之前的 6.0.3 版本。

关于c# - JSON.Net 在构建时抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25011772/

相关文章:

c# - 当 BigInteger 的大小超过 ¼ 千兆字节时,BigInteger 的对数错误

c# - Serilog.Extras.AppSettings 和复杂对象

c# - 文件上传 - 返回 null

silverlight - 方向改变时 WP7 列表宽度问题

jquery - jQuery选择器在Windows Phone 7上不起作用

c# - Newtonsoft 两次反序列化同一个 json 流的有效方法

c# - REST API 包装器设计 : returning dynamic json as JSON. NET JObject/JArray

xml-serialization - JSON.NET、XmlSerializer 和 "Specified"属性

c# - 并非所有代码路径都返回带有 while 循环的值

c# - 无法在 wp7 应用程序中获取 mp3 文件流