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.

Ee358766.Warning(en-us,VS.100).gif Caution:
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 and BindToType methods. The BindToName method takes a Type and returns an assembly and type name. The BindToType method takes an assembly and type name and returns a Type.

See Also

Tasks

Usage of Serialization Binder

Concepts

Serialization and Deserialization