I am new to wcf and windows phone 8 app and calling wcf service(other dev) and trying to deserialize the data it works fine sometimes but most of the times it gives me error
"The data contract type 'TEST.Model.Response`1[[TEST.Model.Announcement, TEST, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' cannot be deserialized because the member 'ResponseData' is not public. Making the member public will fix this error. Alternatively, you can make it internal, and use the InternalsVisibleToAttribute attribute on your assembly in order to enable serialization of internal members - see documentation for more details. Be aware that doing so has certain security implications."
MY Model Class is
public class Response<T> where T: class
{
public string MethodName { get; set; }
public int ResponseCode { get; set; }
public string ResponseMessage { get; set; }
public List<T> ResponseData { get; set; }
}
public class Announcement
{
public int AnnouncementId { get; set; }
public string AnnouncementTitle { get; set; }
public string CreatedBy { get; set; }
public string CreatedDate { get; set; }
public string DataShortVersion { get; set; }
public string ModifiedBy { get; set; }
public string ModifiedDate { get; set; }
public int SortIndex { get; set; }
}
when i try to call as
var request = ar.AsyncState as WebRequest;
Stream reader = request.EndGetResponse(ar).GetResponseStream();
DataContractJsonSerializer jsonSerializer ;\\
jsonSerializer = new DataContractJsonSerializer(typeof(TEST.Model.Response<TEST.Model.Announcement>));
Response<Announcement> objResponse = (Response<Announcement>)jsonSerializer.ReadObject(reader); //error raised
The SSCCE code below works. Try creating one yourself with your problem, and seeing how it is different than the one below. That will likely guide you to your answer.