Επεξεργασία

Κοινή χρήση μέσω


BinaryFormatter Class

Definition

Caution

BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.

Serializes and deserializes an object, or an entire graph of connected objects, in binary format.

public ref class BinaryFormatter sealed : System::Runtime::Serialization::IFormatter
public ref class BinaryFormatter sealed : System::Runtime::Remoting::Messaging::IRemotingFormatter
public sealed class BinaryFormatter : System.Runtime.Serialization.IFormatter
[System.Obsolete("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId="SYSLIB0011", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class BinaryFormatter : System.Runtime.Serialization.IFormatter
public sealed class BinaryFormatter : System.Runtime.Remoting.Messaging.IRemotingFormatter
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class BinaryFormatter : System.Runtime.Remoting.Messaging.IRemotingFormatter
type BinaryFormatter = class
    interface IFormatter
[<System.Obsolete("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId="SYSLIB0011", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type BinaryFormatter = class
    interface IFormatter
type BinaryFormatter = class
    interface IRemotingFormatter
    interface IFormatter
[<System.Runtime.InteropServices.ComVisible(true)>]
type BinaryFormatter = class
    interface IRemotingFormatter
    interface IFormatter
Public NotInheritable Class BinaryFormatter
Implements IFormatter
Public NotInheritable Class BinaryFormatter
Implements IRemotingFormatter
Inheritance
BinaryFormatter
Attributes
Implements

Remarks

Warning: BinaryFormatter is insecure and can't be made secure. For more information, see the BinaryFormatter security guide. The in-box implementation of BinaryFormatter was removed in .NET 9. For more information, see BinaryFormatter migration guide.

Constructors

BinaryFormatter()

Initializes a new instance of the BinaryFormatter class with default values.

BinaryFormatter(ISurrogateSelector, StreamingContext)

Initializes a new instance of the BinaryFormatter class with a given surrogate selector and streaming context.

Properties

AssemblyFormat

Gets or sets the behavior of the deserializer with regards to finding and loading assemblies.

Binder

(Insecure) Gets or sets an object of type SerializationBinder that controls the binding of a serialized object to a type.

Context

Gets or sets the StreamingContext for this formatter.

FilterLevel

Gets or sets the TypeFilterLevel of automatic deserialization the BinaryFormatter performs.

SurrogateSelector

Gets or sets a ISurrogateSelector that controls type substitution during serialization and deserialization.

TypeFormat

Gets or sets the format in which type descriptions are laid out in the serialized stream.

Methods

Deserialize(Stream, HeaderHandler)

Deserializes the specified stream into an object graph. The provided HeaderHandler handles any headers in that stream.

Deserialize(Stream)
Obsolete.

Deserializes the specified stream into an object graph.

DeserializeMethodResponse(Stream, HeaderHandler, IMethodCallMessage)

Deserializes a response to a remote method call from the provided Stream.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Serialize(Stream, Object, Header[])

Serializes the object, or graph of objects with the specified top (root), to the given stream attaching the provided headers.

Serialize(Stream, Object)
Obsolete.

Serializes the object, or graph of objects with the specified top (root), to the given stream.

ToString()

Returns a string that represents the current object.

(Inherited from Object)
UnsafeDeserialize(Stream, HeaderHandler)

Deserializes the specified stream into an object graph. The provided HeaderHandler handles any headers in that stream.

UnsafeDeserializeMethodResponse(Stream, HeaderHandler, IMethodCallMessage)

Deserializes a response to a remote method call from the provided Stream.

Applies to