Exception Field not found: 'System.Runtime.Serialization.XmlObjectSerializerContext.serializerKnownDataContracts'.
-
Saturday, June 14, 2008 12:45 AM
Hi All,
I am calling a business layer method call as below:
List<UsageCategorySummary> prodUsageCategorySummary = ProductDomain.Instance.GetUsageCategories();hidUsageCategory.Value =
this.JsonSerializerHelper(prodUsageCategorySummary);
Helper function code
private
string JsonSerializerHelper(System.Object objRef){
string result = string.Empty; using (MemoryStream memoryStream = new MemoryStream()){
DataContractJsonSerializer serializer = new DataContractJsonSerializer(objRef.GetType()); // Resulting to an exception...// // Exception Field not found: 'System.Runtime.Serialization.XmlObjectSerializerContext.serializerKnownDataContracts'.
using (StreamReader streamReader = new StreamReader(memoryStream))
serializer.WriteObject(memoryStream, objRef);
memoryStream.Position = 0;{
result = streamReader.ReadToEnd();
}
}
return result;}
Exception occurring at the above colored line... any thoughts?!
HydPhani
Answers
-
Saturday, June 14, 2008 9:15 AM
Sorry, but what exactly is the execption (namespace.type) and what is the exact exception message?
/Calle- Marked As Answer by jack 321 Wednesday, June 18, 2008 2:59 AM
-
Sunday, June 15, 2008 12:21 AM
Seems like your object cannot be serialized. This can happen if you have a child List collection.
See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=302308&SiteID=1
Please remember to mark as answered. -- With Regards Shailen Sukul (Shane) Software Architect/Developer/Consultant/Trainer (BSc | Mct | Mcpd | Mcts (Sharepoint (IP), Biztalk, Web, Win, Dist Apps) | Mcsd.NET | Mcsd | Mcad) Ashlen Consulting Services Pty Ltd (http://www.ashlen.com.au) MSN | Skype | GTalk Id: shailensukul Ph: +61 421 277 812 Fax: +61 3 9011 9732 Blog: http://shailensukul.blogspot.com- Proposed As Answer by Shailen Sukul Sunday, June 15, 2008 12:21 AM
- Marked As Answer by jack 321 Wednesday, June 18, 2008 2:59 AM
All Replies
-
Saturday, June 14, 2008 9:15 AM
Sorry, but what exactly is the execption (namespace.type) and what is the exact exception message?
/Calle- Marked As Answer by jack 321 Wednesday, June 18, 2008 2:59 AM
-
Sunday, June 15, 2008 12:21 AM
Seems like your object cannot be serialized. This can happen if you have a child List collection.
See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=302308&SiteID=1
Please remember to mark as answered. -- With Regards Shailen Sukul (Shane) Software Architect/Developer/Consultant/Trainer (BSc | Mct | Mcpd | Mcts (Sharepoint (IP), Biztalk, Web, Win, Dist Apps) | Mcsd.NET | Mcsd | Mcad) Ashlen Consulting Services Pty Ltd (http://www.ashlen.com.au) MSN | Skype | GTalk Id: shailensukul Ph: +61 421 277 812 Fax: +61 3 9011 9732 Blog: http://shailensukul.blogspot.com- Proposed As Answer by Shailen Sukul Sunday, June 15, 2008 12:21 AM
- Marked As Answer by jack 321 Wednesday, June 18, 2008 2:59 AM

