This documentation is archived and is not being maintained.

IExtensibleDataObject Interface

Provides a data structure to store extra data encountered by the XmlObjectSerializer during deserialization of a type marked with the DataContractAttribute attribute.

Namespace:  System.Runtime.Serialization
Assembly:  System.Runtime.Serialization (in System.Runtime.Serialization.dll)

public interface class IExtensibleDataObject

The IExtensibleDataObject type exposes the following members.

Public propertyExtensionDataGets or sets the structure that contains extra data.

The IExtensibleDataObject interface provides a single property that sets or returns a structure used to store data that is external to a data contract. The extra data is stored in an instance of the ExtensionDataObject class and accessed through the ExtensionData property. In a roundtrip operation where data is received, processed, and sent back, the extra data is sent back to the original sender intact. This is useful to store data received from future versions of the contract. If you do not implement the interface, any extra data is ignored and discarded during a roundtrip operation.

To use this versioning feature

  1. Implement the IExtensibleDataObject interface in a class.

  2. Add the ExtensionData property to your type.

  3. Add a private member of type ExtensionDataObject to the class.

  4. Implement get and set methods for the property using the new private member.

  5. Apply the DataContractAttribute attribute to the class. Set the Name and Namespace properties to appropriate values if necessary.

For more information about versioning of types, see Data Contract Versioning. For information about creating forward-compatible data contracts, see Forward Compatible Data Contracts. For more information about data contracts, see Using Data Contracts.

The following code shows an instance of a type (PersonVersion2) that is the second version of a serializable type (Person). The second version contains extra data (ID field) that is not present in the first version.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.