Cannot find DataContractJsonSerializer in VS2010

情到浓时终转凉″ 提交于 2019-12-22 06:26:07

问题


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)

回答1:


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



来源:https://stackoverflow.com/questions/4604675/cannot-find-datacontractjsonserializer-in-vs2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!