BinaryFormatter.Deserialize 方法  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将流反序列化为对象图形。
重载
| Deserialize(Stream) | 
		已过时.
	 将指定的流反序列化为对象图形。 | 
| Deserialize(Stream, HeaderHandler) | 将指定的流反序列化为对象图形。 所提供的 HeaderHandler 处理该流中的任何标题。 | 
注解
重要
使用不受信任的数据调用此方法存在安全风险。 仅使用受信任的数据调用此方法。 有关详细信息,请参阅 验证所有输入。
Deserialize(Stream)
- Source:
- BinaryFormatter.Core.cs
- Source:
- BinaryFormatter.Core.cs
- Source:
- BinaryFormatter.Core.cs
注意
BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.
将指定的流反序列化为对象图形。
public:
 virtual System::Object ^ Deserialize(System::IO::Stream ^ serializationStream);[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 object Deserialize (System.IO.Stream serializationStream);public object Deserialize (System.IO.Stream serializationStream);[<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}")>]
abstract member Deserialize : System.IO.Stream -> obj
override this.Deserialize : System.IO.Stream -> objabstract member Deserialize : System.IO.Stream -> obj
override this.Deserialize : System.IO.Stream -> objPublic Function Deserialize (serializationStream As Stream) As Object参数
- serializationStream
- Stream
要从其中反序列化对象图形的流。
返回
对象图的顶级(根)。
实现
- 属性
例外
              serializationStream 为 null。
该 serializationStream 支持查找,但其长度为 0。
或
输入流不表示格式正确的 BinaryFormatter 序列化有效负载。
或
从输入流反序列化对象时出错。
              InnerException 属性可能包含有关根本原因的详细信息。
调用方没有所要求的权限。
ASP.NET Core 5 及更高版本:除非在项目文件中重新启用功能,否则BinaryFormatter始终引发。 有关详细信息,请参阅修复 BinaryFormatter 过时和禁用错误。
注解
警告
              BinaryFormatter 不安全,无法确保安全。 有关详细信息,请参阅 BinaryFormatter 安全指南。
若要成功反序列化,流中的当前位置必须位于对象图的开头。
重要
使用不受信任的数据调用此方法存在安全风险。 仅使用受信任的数据调用此方法。 有关详细信息,请参阅 验证所有输入。
适用于
Deserialize(Stream, HeaderHandler)
将指定的流反序列化为对象图形。 所提供的 HeaderHandler 处理该流中的任何标题。
public:
 virtual System::Object ^ Deserialize(System::IO::Stream ^ serializationStream, System::Runtime::Remoting::Messaging::HeaderHandler ^ handler);public object Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler);abstract member Deserialize : System.IO.Stream * System.Runtime.Remoting.Messaging.HeaderHandler -> obj
override this.Deserialize : System.IO.Stream * System.Runtime.Remoting.Messaging.HeaderHandler -> objPublic Function Deserialize (serializationStream As Stream, handler As HeaderHandler) As Object参数
- serializationStream
- Stream
要从其中反序列化对象图形的流。
- handler
- HeaderHandler
处理 serializationStream 中的任何标题的 HeaderHandler。 可以为 null。
返回
反序列化的对象或对象图形的顶级对象(根)。
实现
例外
              serializationStream 为 null。
调用方没有所要求的权限。
注解
警告
              BinaryFormatter 不安全,无法确保安全。 有关详细信息,请参阅 BinaryFormatter 安全指南。
标头仅用于特定的远程处理应用程序。
若要成功反序列化,流中的当前位置必须位于对象图的开头。
重要
使用不受信任的数据调用此方法存在安全风险。 仅使用受信任的数据调用此方法。 有关详细信息,请参阅 验证所有输入。