BinaryFormatter.UnsafeDeserialize(Stream, HeaderHandler) BinaryFormatter.UnsafeDeserialize(Stream, HeaderHandler) BinaryFormatter.UnsafeDeserialize(Stream, HeaderHandler) BinaryFormatter.UnsafeDeserialize(Stream, HeaderHandler) Method

定義

將指定的資料流還原序列化至物件圖形。Deserializes the specified stream into an object graph. 所提供的 HeaderHandler 會處理該資料流中的任何標頭。The provided HeaderHandler handles any headers in that stream.

public:
 System::Object ^ UnsafeDeserialize(System::IO::Stream ^ serializationStream, System::Runtime::Remoting::Messaging::HeaderHandler ^ handler);
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public object UnsafeDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler);
member this.UnsafeDeserialize : System.IO.Stream * System.Runtime.Remoting.Messaging.HeaderHandler -> obj
Public Function UnsafeDeserialize (serializationStream As Stream, handler As HeaderHandler) As Object

參數

serializationStream
Stream Stream Stream Stream

要還原序列化物件圖形的來源資料流。The stream from which to deserialize the object graph.

handler
HeaderHandler HeaderHandler HeaderHandler HeaderHandler

處理在 serializationStream 中任何標頭的 HeaderHandlerThe HeaderHandler that handles any headers in the serializationStream. 可以是 nullCan be null.

傳回

物件圖形的已還原序列化物件或最上層物件 (根)。The deserialized object or the top object (root) of the object graph.

例外狀況

serializationStreamnullThe serializationStream is null.

serializationStream 支援搜尋,但是其長度為 0。The serializationStream supports seeking, but its length is 0.

呼叫端沒有必要的使用權限。The caller does not have the required permission.

備註

標頭僅用於特定的遠端處理應用程式。Headers are used only for specific remoting applications.

這個方法會SecurityAction.LinkDemand使用防止不受信任的程式碼呼叫它; 只有直接呼叫者才需要擁有SecurityPermissionAttribute.SerializationFormatter許可權。This method uses SecurityAction.LinkDemand to prevent it from being called from untrusted code; only the immediate caller is required to have SecurityPermissionAttribute.SerializationFormatter permission. 如果您的程式碼可以從部分信任的程式碼呼叫, 請勿使用這個方法。Do not use this method if your code can be called from partially trusted code. 在部分信任的案例中Deserialize , 請改用。In partially trusted scenarios, use Deserialize instead. 在完全信任的情況UnsafeDeserialize下, 會提供Deserialize比更好的效能。In full trust scenarios, UnsafeDeserialize provides better performance than Deserialize.

若要成功還原序列化, 資料流程中的目前位置必須位於物件圖形的開頭。For successful deserialization, the current position in the stream must be at the beginning of the object graph.

重要

使用不信任的資料呼叫此方法,會造成安全性上的風險。Calling this method with untrusted data is a security risk. 呼叫此方法時,請一律使用信任的資料。Call this method only with trusted data. 如需詳細資訊,請參閱資料驗證For more information, see Data Validation.

安全性

SecurityPermission
提供序列化服務。To provide serialization services. 相關聯的SerializationFormatter列舉:。Associated enumeration: SerializationFormatter.

適用於