BinarySerializationFormatterBinder Property

KGy SOFT Core Libraries Help
Gets or sets the SerializationBinder that performs type conversions to and from string.
See the Remarks section for details.

Namespace:  KGySoft.Serialization.Binary
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 6.0.0

public SerializationBinder? Binder { get; set; }

Property Value

Type: SerializationBinder



By default, the binder is not called for natively supported types.

If the ForceRecursiveSerializationOfSupportedTypes flag is set in Options, then the binder is called for the non-primitive natively supported types.

This formatter does not call the binder types that have element types, for constructed generic types and generic parameter types. Instead, the binder is called only for the element types, the generic type definition and the generic arguments separately.

Note Note
In .NET Framework 3.5 setting this property has no effect during serialization unless the binder implements the ISerializationBinder interface.
Tip Tip
If you serialize forwarded types that have no defined forwarding by the TypeForwardedToAttribute and TypeForwardedFromAttribute attributes, then to ensure emitting compatible assembly identities on different .NET platforms use the ForwardedTypesSerializationBinder, define the missing mappings by the AddType method and set its WriteLegacyIdentity property to . Alternatively, you can use the WeakAssemblySerializationBinder or you can just serialize the object without assembly information by setting the OmitAssemblyQualifiedNames flag in the Options.
Security note Security Note

If you use binders for deserialization, then setting the SafeMode flag in the Options cannot prevent loading assemblies by the binder itself. The binders in this library that can perform automatic type resolving, such the WeakAssemblySerializationBinder and ForwardedTypesSerializationBinder have their own SafeMode property. Make sure to set them to  to prevent loading assemblies by the binders themselves.

See the security notes at the Remarks section of the BinarySerializationFormatter class for more details.

See Also