在 VS2010 中找不到 DataContractJsonSerializer [英] Cannot find DataContractJsonSerializer in VS2010

查看:35
本文介绍了在 VS2010 中找不到 DataContractJsonSerializer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个演示 Silverlight 应用程序,我想做一些简单的 JSON.我找到了 System.Runtime.SerializationMSDN 上的 .Json.DataContractJsonSerializer 类,但我似乎无法在 Visual Studio 2010 中成功引用它.

我已经添加了对 System.Runtime.Serialization 的引用,但是如果我有一个 DataContractJsonSerializer(即使使用完全限定的类名),我仍然会收到编译错误.我的项目配置为 Silverlight 4.添加引用时,程序集确实有 2.0 版本号,但我找不到 4.0 版本的程序集.

为什么我不能使用这个类?

<前>命名空间:System.Runtime.Serialization.Json程序集:System.Runtime.Serialization(在 System.Runtime.Serialization.dll 中)

解决方案

有一个 System.Runtime.Serialization.Json.dll 文件,但您无法在该文件中找到 System.Runtime.Serialization.Json 命名空间.您实际上必须引用 System.ServiceModel.Web.dll 库,这就是 DataContractJsonSerializer 类所在的位置.在我的机器上,DLL 位于:C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.ServiceModel.Web.dll

I am working on a demo Silverlight app and I'd like to do some simple JSON. I found the System.Runtime.Serialization.Json.DataContractJsonSerializer class on MSDN, but I can't seem to reference it successfully in Visual Studio 2010.

I have added a reference to System.Runtime.Serialization, but I still get a compile error if I have a DataContractJsonSerializer (even with a fully qualified class name. My project is configured to Silverlight 4. The assembly does have a 2.0 version number when I add the reference, but I can't find a version 4.0 assembly.

Why can't I use this class?

Namespace:  System.Runtime.Serialization.Json
Assembly:  System.Runtime.Serialization (in System.Runtime.Serialization.dll)

解决方案

There is a System.Runtime.Serialization.Json.dll file but that is not where you can find the System.Runtime.Serialization.Json namespace. You actually have to reference the System.ServiceModel.Web.dll library and that is where the DataContractJsonSerializer class. On my machine, the DLL was found here: C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.ServiceModel.Web.dll

这篇关于在 VS2010 中找不到 DataContractJsonSerializer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆