Share via


Binary Serialization

Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created.

When implementing a serialization mechanism in an object-oriented environment, you have to make a number of tradeoffs between ease of use and flexibility. The process can be automated to a large extent, provided you are given sufficient control over the process. For example, situations may arise where simple binary serialization is not sufficient, or there might be a specific reason to decide which fields in a class need to be serialized. The following sections examine the robust serialization mechanism provided with the .NET Framework and highlight a number of important features that allow you to customize the process to meet your needs.

In This Section

  • Serialization Concepts
    Discusses two scenarios where serialization is useful: when persisting data to storage and when passing objects across application domains.
  • Basic Serialization
    Describes how to use the binary and SOAP formatters to serialize objects.
  • Selective Serialization
    Describes how to prevent some members of a class from being serialized.
  • Custom Serialization
    Describes how to customize serialization for a class by using the ISerializable interface.
  • Steps in the Serialization Process
    Describes the course of action serialization takes when the Serialize method is called on a formatter.
  • Versioning
    Provides guidelines for dealing with serializing classes across different versions.
  • Serialization Guidelines
    Provides some general guidelines for deciding when to serialize an object.