The type or namespace name 'DataContractJsonSerializer' does not exist, Json

3958
3
10-27-2010 08:55 AM
jayshukla
New Contributor III
Hi There,
I am trying to run the sample from Interactive SDK and getting this issue, when I build the solution, below is the error that I am getting. I have proper references in place but not sure what I am missing here.

BTW, here is the link for the sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#AddGraphics

using System.Runtime.Serialization;
using System.Runtime.Serialization.Json; 

I would really appreciate any feedback.

Thanks
Jay


Error 1 The type or namespace name 'DataContractJsonSerializer' does not exist in the namespace 'System.Runtime.Serialization.Json' (are you missing an assembly reference?)


        internal static T DeserializeJson<T>(string json)
        {
            T objectInstance = Activator.CreateInstance<T>();
            System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(System.Text.Encoding.Unicode.GetBytes(json));
           
            System.Runtime.Serialization.Json.DataContractJsonSerializer jsonSerializer =
                new System.Runtime.Serialization.Json.DataContractJsonSerializer(objectInstance.GetType());



            objectInstance = (T)jsonSerializer.ReadObject(memoryStream);
            memoryStream.Close();
            return objectInstance;
        } [/SIZE]
0 Kudos
3 Replies
Charles__Jamie_Phillips
New Contributor III
You are missing a reference.  I believe the referece is System.Web and that should take care of the issue.  It is one of those gotchas.
0 Kudos
StevenMorlock
New Contributor II
Namespace:  System.Runtime.Serialization.Json
Assembly:  System.ServiceModel.Web (in System.ServiceModel.Web.dll)

in VS2010, just select it and press F1 for help. this shows you the necessary assembly.
0 Kudos
jayshukla
New Contributor III
Hi Folks,

Thanks a lot of quick feedback. I was just missing this DLL. Now it's all good to go.

Thanks again.
Jay
0 Kudos