SecurityException.GetObjectData(SerializationInfo, StreamingContext) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
注意
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
中重新构造异常。