If you use Data Contracts, then probably your classes implement the IExtensibleDataObject interface to allow (de)serialization of different versions of the data contract. I won’t go into details about the use of ExtensionDataObject, the type of the ExtensionData property you need to implement. I just want to point out a possible scenario, using sample code similar to that of MSDN:
If you serialize an object of the type used in this example, Person, using a BinaryFormatter, you will get the following exception:
System.Runtime.Serialization.SerializationException: Type ‘System.Runtime.Serialization.ExtensionDataObject’ in Assembly ‘System.Runtime.Serialization, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b77a5c561934e089’ is not marked as serializable.
The solution is to mark the private extensionData field as non-serialized: