共用方式為


SecurityException.GetObjectData(SerializationInfo, StreamingContext) 方法

定義

警告

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

使用 SecurityException 的相關資訊來設定 SerializationInfo

public:
 override void GetObjectData(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
public override void GetObjectData (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public override void GetObjectData (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Security.SecurityCritical]
public override void GetObjectData (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
override this.GetObjectData : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> unit
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
override this.GetObjectData : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> unit
[<System.Security.SecurityCritical>]
override this.GetObjectData : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> unit
Public Overrides Sub GetObjectData (info As SerializationInfo, context As StreamingContext)

參數

info
SerializationInfo

SerializationInfo,包含所擲回之例外狀況的相關序列化物件資料。

context
StreamingContext

包含有關來源或目的端內容資訊的 StreamingContext

屬性

例外狀況

info 參數為 null

範例

下列程式碼示範如何使用 GetObjectData 方法來顯示 物件中包含的 SerializationInfo 許可權狀態。

Display("Demonstrating the use of the GetObjectData "
    "method.");
SerializationInfo^ entryPointSerializatonInfo =
    gcnew SerializationInfo(TestSecurityException::typeid,
    gcnew FormatterConverter);
exception->GetObjectData(entryPointSerializatonInfo,
    *gcnew StreamingContext(StreamingContextStates::All));
Display("The FirstPermissionThatFailed from the call"
    " to GetObjectData is: ");
Display(entryPointSerializatonInfo->GetString(
    "FirstPermissionThatFailed"));
Display("Demonstrating the use of the GetObjectData method.");
SerializationInfo si = new SerializationInfo(
    typeof(EntryPoint), new FormatterConverter());
sE.GetObjectData(si, 
    new StreamingContext(StreamingContextStates.All));
Display("The FirstPermissionThatFailed from the " +
    "call to GetObjectData is: ");
Display(si.GetString("FirstPermissionThatFailed"));
    Display("Demonstrating the use of the GetObjectData method.")
    Dim si As New SerializationInfo( _
        GetType(EntryPoint), New FormatterConverter())
    sE.GetObjectData(si, _
        New StreamingContext(StreamingContextStates.All))
    Display("The FirstPermissionThatFailed from the " & _
        "call to GetObjectData is: ")
    Display(si.GetString("FirstPermissionThatFailed"))
End Try

備註

GetObjectData 會以目標為序列化的所有例外狀況物件資料設定 SerializationInfo。 在還原序列化期間,例外狀況是從透過資料流傳輸的 SerializationInfo 所重新組成。

適用於

另請參閱