问题
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