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 .NET and highlight a number of important features that allow you to customize the process to meet your needs.


The state of a UTF-8 or UTF-7 encoded object is not preserved if the object is serialized and deserialized using different .NET Framework versions.


Binary serialization can be dangerous. Never deserialize data from an untrusted source and never round-trip serialized data to systems not under your control.

As the nature of binary serialization allows the modification of private members inside an object and therefore changing the state of it, other serialization frameworks like JSON.NET which operate on the public API surface are recommended.

Binary serialization in .NET Core

.NET Core supports binary serialization with a subset of types. You can see the list of supported types in the Serializable types section. The defined set of types are guaranteed to be serializable between .NET Framework 4.5.1 and later versions and .NET Core 2.0 and later versions. Other .NET implementations, such as Mono, aren't officially supported but should also be working.

Serializable types

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.

Version Tolerant Serialization
Explains how to create serializable types that can be modified over time without causing applications to throw exceptions.

Serialization Guidelines
Provides some general guidelines for deciding when to serialize an object.


Contains classes that can be used for serializing and deserializing objects.

XML and SOAP Serialization
Describes the XML serialization mechanism that is included with the common language runtime.

Security and Serialization
Describes the secure coding guidelines to follow when writing code that performs serialization.

Remote Objects
Describes the various communications methods available in the .NET Framework for remote communications.

XML Web Services Created Using ASP.NET and XML Web Service Clients
Provides topics that describe and explain how to program XML Web services created using ASP.NET.