System.Runtime.Serialization Namespace

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

The System.Runtime.Serialization namespace contains classes that can be used for serializing and deserializing objects. Serialization is the process of converting an object or a graph of objects into a linear sequence of bytes for either storage or transmission to another location. Deserialization is the process of taking in stored information and recreating objects from it.

The ISerializable interface provides a way for classes to control their own serialization behavior. Classes in the System.Runtime.Serialization.Formatters namespace control the actual formatting of various data types encapsulated in the serialized objects.

Formatters that serialize and deserialize objects to and from a particular format can be found in the System.Runtime.Serialization.Formatters namespace.

Classes

Class Description
CollectionDataContractAttribute When applied to a collection type, enables custom specification of the collection item elements. This attribute can be applied only to types that are recognized by the DataContractSerializer as valid, serializable collections.
ContractNamespaceAttribute Specifies the CLR namespace and XML namespace of the data contract.
DataContractAttribute Specifies that the type defines or implements a data contract and can be serialized by a serializer, such as the DataContractSerializer.
DataContractResolver Provides a mechanism for dynamically mapping types to and from xsi:type representations during serialization and deserialization.
DataContractSerializer Serializes and deserializes an instance of a type into an XML stream or document using a supplied data contract. This class cannot be inherited.
DataContractSerializerSettings Specifies data contract serializer settings.
DataMemberAttribute When applied to the member of a type, specifies that the member is part of a data contract and is serializable by the DataContractSerializer.
DateTimeFormat Specifies date-time format options.
EnumMemberAttribute Specifies that the field is an enumeration member and should be serialized.
IgnoreDataMemberAttribute When applied to the member of a type, specifies that the member is not part of a data contract and is not serialized.
InvalidDataContractException The exception that is thrown when the DataContractSerializer encounters an invalid data contract during serialization and deserialization.
KnownTypeAttribute Specifies types that should be recognized by the DataContractSerializer when serializing or deserializing a given type.
OnDeserializedAttribute When applied to a method, specifies that the method is called immediately after deserialization of the object.
OnDeserializingAttribute When applied to a method, specifies that the method is called during deserialization of an object.
OnSerializedAttribute When applied to a method, specifies that the method is called after serialization of an object graph.
OnSerializingAttribute When applied to a method, specifies that the method is called before serialization of an object.
SerializationException The exception thrown when an error occurs during serialization or deserialization.
XmlObjectSerializer Provides the base class used to serialize objects as XML streams or documents. This class is abstract.

Structures

Structure Description
StreamingContext Describes the source and destination of a given serialized stream, and provides an additional caller-defined context.

Enumerations

Enumeration Description
EmitTypeInformation Specifies how often to emit type information.