Note
Even if this flag is enabled, non-serializable types will not be serialized automatically. Use the RecursiveSerializationAsFallback to
enable serialization of such types.
[FlagsAttribute]
public enum BinarySerializationOptions
<FlagsAttribute>
Public Enumeration BinarySerializationOptions
[FlagsAttribute]
public enum class BinarySerializationOptions
[<FlagsAttribute>]
type BinarySerializationOptions
None | 0x0000 | All options are disabled. |
ForceRecursiveSerializationOfSupportedTypes | 0x0001 | Apart from primitive types, strings and arrays forces to serialize every type recursively. If SurrogateSelector is set, then the surrogate selectors will be tried to used even for the supported types (as if TryUseSurrogateSelectorForAnyType was also enabled). This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
ForcedSerializationValueTypesAsFallback | 0x0002 | This option makes possible to serialize ValueTypes (struct) that are not marked by SerializableAttribute. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled Obsolete. |
RecursiveSerializationAsFallback | 0x0004 | Makes possible to serialize any non-natively supported types if they are not marked by SerializableAttribute. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
IgnoreSerializationMethods | 0x0008 | If a type has methods decorated by OnSerializingAttribute, OnSerializedAttribute, OnDeserializingAttribute or OnDeserializedAttribute, or the type implements IDeserializationCallback, then these methods are called during the process. By setting this flag these methods can be ignored. This flag is considered both on serialization and deserialization. Default state at serialization methods in BinarySerializer: Disabled |
IgnoreIBinarySerializable | 0x0010 | This flag ignores IBinarySerializable implementations. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
OmitAssemblyQualifiedNames | 0x0020 | If enabled, type references will be stored without assembly identification. This can make possible to restore a type even if the version of the assembly has been modified since last serialization while makes serialized data more compact; however, it cannot be guaranteed that the correct type will be even found on deserialization without specifying the expected types. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
IgnoreObjectChanges | 0x0040 | This option makes possible to deserialize an object, which has been changed since last serialization. When this option is enabled, names of the base classes, and fields that have been serialized but have been since then removed, will be ignored. This flag is considered on deserialization. Default state at serialization methods in BinarySerializer: Disabled |
IgnoreTypeForwardedFromAttribute | 0x0080 | When this flag is enabled, every type will be serialized with its actual assembly identity rather than considering the value of an existing TypeForwardedFromAttribute. This flag is ignored if OmitAssemblyQualifiedNames is enabled. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
IgnoreISerializable | 0x0100 | This flag ignores ISerializable implementations for natively not supported types, forcing to serialize a default object graph (unless an applicable surrogate selector is defined). This flag is considered both on serialization and deserialization. Default state at serialization methods in BinarySerializer: Disabled |
IgnoreIObjectReference | 0x0200 | This flag ignores IObjectReference implementations. This flag is considered on deserialization. Default state at serialization methods in BinarySerializer: Disabled |
CompactSerializationOfStructures | 0x0400 | If a ValueType (struct) contains no references, then by enabling this option the instance will be serialized in a compact way form if possible. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Enabled |
TryUseSurrogateSelectorForAnyType | 0x0800 | If this flag is enabled while SurrogateSelector is set, then the selector is tried to be used even for natively supported types. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
SafeMode | 0x1000 | If this flag is enabled, then it is ensured that no assembly loading is allowed during deserialization. All of the assemblies that are referred by the serialization stream must be preloaded before starting the deserialization. Non-natively supported types, whose assembly qualified names are stored in the serialization stream must be explicitly declared as expected types in the deserialization methods, including enums. Additionally, safe mode ensures that during the deserialization natively supported collections are allocated with limited capacity to prevent possible attacks that can cause OutOfMemoryException. Deserializing an invalid stream still may cause to throw a SerializationException. It also disallows deserializing the natively not supported non-serializable types, though this can be relaxed by enabling the AllowNonSerializableExpectedCustomTypes flag. This flag is considered on deserialization. Default state at serialization methods in BinarySerializer: Enabled |
AllowNonSerializableExpectedCustomTypes | 0x2000 | Indicates that recursively serialized types that are indicated as expected types at the deserialization methods should be able to be deserialized in SafeMode even if they are not marked by the SerializableAttribute. This flag is considered on deserialization. Default state at serialization methods in BinarySerializer: Disabled |