Hey,
Im building a mobile application in silverlight, so im using a stripped version of .NET 3.5 and VS 2010. Basically, i just make a HTTP request to a server that returns the details about the vechicle.
Heres my class code:
Code:
    [DataContract]
    public class Vehicle
    {
        [DataMember]
        string m_model;
        public string Model
        {
            get { return m_model; }                   //im aware of the get;set; syntax
            set { m_BodyStyle = m_model; }     // but i did it this way to try and debug my problem
        }
 //with a bunch more data members, not sure if you want to see them, cut them out for the sake of space. Its pretty long, but can post them if need be.
And this is the Async request code:
Code:
            Vehicle car = new Vehicle();
            //try
            {
                HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;
                WebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult);
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Vehicle));
                car = (Vehicle)ser.ReadObject(response.GetResponseStream());   
            }
However, "car = (Vehicle)ser.ReadObject(response.GetResponseStream()); " gives an "System.InvalidCastException was unhandled" error. I assume the data coming from the server is in the wrong format, but i dont know how to fix the problem.
Any extra code you want to see can be provided, no worries. Im just kinda stumped by this.
Any input is greatly appreciated!
Thanks,
-M