WeakAssemblySerializationBinder Class

Provides a SerializationBinder instance for IFormatter implementations that can ignore version and token information of stored assembly name. This makes possible to deserialize objects stored in different version of the original assembly. It also can make any IFormatter safe in terms of prohibiting loading assemblies during the deserialization if the SafeMode property is .

Definition

Namespace: KGySoft.Serialization.Binary
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
public sealed class WeakAssemblySerializationBinder : SerializationBinder, 
	ISerializationBinder
Inheritance
Object    SerializationBinder    WeakAssemblySerializationBinder
Implements
ISerializationBinder

Remarks

  Security Note

If a deserialization stream may come from an untrusted source, then make sure to set the SafeMode property to to prevent loading assemblies when resolving types. Please note though that you cannot use this class for BinarySerializationFormatter when the SafeMode flag is enabled in its Options property, even if the SafeMode property is set to .

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

The WeakAssemblySerializationBinder class allows resolving type information by weak assembly identity, or by completely ignoring assembly information (if IgnoreAssemblyNameOnResolve property is .)

It also makes possible to prevent loading assembles during deserialization if the SafeMode property is .

If WeakAssemblySerializationBinder is used on serialization, then it can omit assembly information from the serialization stream if the OmitAssemblyNameOnSerialize property is .

Constructors

WeakAssemblySerializationBinderInitializes a new instance of the WeakAssemblySerializationBinder class

Properties

IgnoreAssemblyNameOnResolve Gets or sets whether an existing assembly name is allowed to be completely ignored on deserialization.
Default value: .
OmitAssemblyNameOnSerialize Gets or sets whether assembly name should be completely omitted on serialization.
Default value: .
SafeMode Gets or sets whether loading assemblies is prohibited on deserialization.
Default value: .

Methods

BindToName When OmitAssemblyNameOnSerialize is , suppresses the assembly name on serialization. Otherwise, returns for both assembly and type names, indicating that the original names should be used.
(Overrides SerializationBinderBindToName(Type, String, String))
BindToType Retrieves a type by its assemblyName and typeName.
(Overrides SerializationBinderBindToType(String, String))

Extension Methods

Convert Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.
(Defined by ObjectExtensions)
ConvertTTarget Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions)
In Gets whether item is among the elements of set.
See the Examples section of the generic InT(T, T) overload for an example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)

See Also