Redigera

Dela via


BinaryFormatter Constructors

Definition

Initializes a new instance of the BinaryFormatter class.

Overloads

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.

BinaryFormatter()

Source:
BinaryFormatter.cs
Source:
BinaryFormatter.cs
Source:
BinaryFormatter.cs
Source:
BinaryFormatter.cs

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

public:
 BinaryFormatter();
public BinaryFormatter ();
Public Sub New ()

Remarks

Warning

BinaryFormatter is insecure and can't be made secure. For more information, see the BinaryFormatter security guide.

This constructor sets the properties of the BinaryFormatter object as follows:

Property Type Condition
SurrogateSelector null
Context A StreamingContext with a value that indicates that serialized data can be transmitted to or received from any of the other contexts. (StreamingContextStates.All)

Applies to

BinaryFormatter(ISurrogateSelector, StreamingContext)

Source:
BinaryFormatter.cs
Source:
BinaryFormatter.cs
Source:
BinaryFormatter.cs
Source:
BinaryFormatter.cs

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

public:
 BinaryFormatter(System::Runtime::Serialization::ISurrogateSelector ^ selector, System::Runtime::Serialization::StreamingContext context);
public BinaryFormatter (System.Runtime.Serialization.ISurrogateSelector? selector, System.Runtime.Serialization.StreamingContext context);
public BinaryFormatter (System.Runtime.Serialization.ISurrogateSelector selector, System.Runtime.Serialization.StreamingContext context);
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.ISurrogateSelector * System.Runtime.Serialization.StreamingContext -> System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Public Sub New (selector As ISurrogateSelector, context As StreamingContext)

Parameters

selector
ISurrogateSelector

The ISurrogateSelector to use. Can be null.

context
StreamingContext

The source and destination for the serialized data.

Remarks

Warning

BinaryFormatter is insecure and can't be made secure. For more information, see the BinaryFormatter security guide.

Initializes a new BinaryFormatter for serialization or deserialization of objects from the specified Stream.

The serialization or deserialization process uses the specified ISurrogateSelector to search for surrogates that are registered for the object types you want to deserialize. Surrogates are helpers that serialize and deserialize objects of specific classes. The default ISurrogateSelector cannot handle the serialization of objects that derive from the MarshalByRefObject for remoting purposes. In a remoting situation the specified ISurrogateSelector replaces the object derived from MarshalByRefObject with a ObjRef object that is serialized by the specified surrogate selector. Therefore, if you want to use remote objects, set the selector parameter to an instance of RemotingSurrogateSelector. If you do not need surrogates, set the selector parameter to be null.

Applies to