Controlling Serialization and Deserialization with SerializationBinder

During serialization, a formatter transmits the information required to create an instance of an object of the correct type and version. This information generally includes the full type name and assembly name of the object. By default, deserialization uses this information to create an instance of an identical object. Some users may need to control which class to serialize and deserialize, either because the original class may not exist on the machine performing deserialization, the original class has moved between assemblies, or a different version of the class is required on the server and client. For more information, see Usage of Serialization Binder.


This functionality is only available when using the BinaryFormatter or the NetDataContractSerializer.

Using SerializationBinder

SerializationBinder is an abstract class used to control the actual types used during serialization and deserialization. To control the types used during serialization and deserialization, derive a class from SerializationBinder and override the BindToName(Type, String, String) and BindToType(String, String) methods. The BindToName(Type, String, String) method takes a Type and returns an assembly and type name. The BindToType(String, String) method takes an assembly and type name and returns a Type.

See also