System.Runtime.Serialization.OptionalFieldAttribute Class

Specifies that a field can be missing from a serialization stream so that the System.Runtime.Serialization.Formatters.Binary.BinaryFormatter and the System.Runtime.Serialization.Formatters.Soap.SoapFormatter does not throw an exception.

See Also: OptionalFieldAttribute Members


[System.AttributeUsage(System.AttributeTargets.Field, Inherited=false)]
public sealed class OptionalFieldAttribute : Attribute


This attribute allows you to specify that new fields in a serializable type (a type to which the SerializableAttribute is applied to) are ignored by the System.Runtime.Serialization.Formatters.Binary.BinaryFormatter or the System.Runtime.Serialization.Formatters.Soap.SoapFormatter. This enables version-tolerant serialization of types created for older versions of an application that serializes data. For example, when the formatters encounter a stream produced by a version that does not include the new fields, no exception is thrown, and the existing data on the older type is processed as normal.


Namespace: System.Runtime.Serialization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0