.NET Framework Bookmark and Share   
 index > .NET Remoting and Runtime Serialization > DataContractSerializer serializing backing fields and throwing exceptions
 

DataContractSerializer serializing backing fields and throwing exceptions

What would cause the DataContractSerializer to throw the following exception?

System.Runtime.Serialization.SerializationException was unhandled by user code
Message="Type 'System.RuntimeType' with data contract name 'RuntimeType:http://schemas.datacontract.org/2004/07/System' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer."

WHen it does succeed to serialize my object, ir produces the following XML;



I have removed all DataMember attributes on properties of the targeted class, yet the serializer still throws and exception, serializes backing fields for certain properties and ignores others. Any ideas on what is going on here? This is the XML created for the base class.

<d5p1:Filter xmlns:d6p1="http://schemas.datacontract.org/2004/07/OCC600.Infrastructure.Dictionary.BusinessEntities" i:type="d6p1:SitMessageFilter">
<d6p1:_x003C_Alias_x003E_k__BackingField i:nil="true" />
<d6p1:_x003C_EntityType_x003E_k__BackingField>None</d6p1:_x003C_EntityType_x003E_k__BackingField>
<d6p1:description i:nil="true" />
<d6p1:editState>Changed</d6p1:editState>
<d6p1:id>0</d6p1:id>
<d6p1:isInit>true</d6p1:isInit>
<d6p1:key>0</d6p1:key>
<d6p1:name i:nil="true" />
<d6p1:timeStamp>2009-09-10T21:20:29.67825Z</d6p1:timeStamp>
<d6p1:_x003C_DataType_x003E_k__BackingField xmlns:d7p1="http://schemas.datacontract.org/2004/07/System" i:type="d7p1:RuntimeType" />
</d5p1:Filter>

knji
Argh. Problem resulting from missing [DataContact] attribute. I though the DCS recognized the [Serializable] attribute.
knji

You can use google to search for other answers

Custom Search

More Threads

• Fixup Problem with Serialization Surrogate
• remoting client problem with asp.net
• Network Logon Failed-Home network
• extending .net remoting - optional compression sink in the client side
• object pooling
• Serialize to async filestream
• need help with inheriting 'System.MarshalByRefObject' for remoting
• Exception Stack Trace
• Using remoting features inside a .NET applet loaded in a tag object
• remoting vs webservices