BinaryFormatter Constructors
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the BinaryFormatter class.
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. |
- 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
Upozornenie
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
.NET 9 a ďalšie verzie
Produkt | Verzie |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- 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
Upozornenie
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
.NET 9 a ďalšie verzie
Produkt | Verzie |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Pripomienky k produktu .NET
.NET je open-source projekt. Ak chcete poskytnúť pripomienky, vyberte prepojenie: