SecurityException.GetObjectData(SerializationInfo, StreamingContext) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Attention
This API supports obsolete formatter-based serialization. It should not be called or extended by application code.
Définit l’élément SerializationInfo avec des informations concernant l’SecurityException.
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)
Paramètres
- info
- SerializationInfo
SerializationInfo qui contient les données d'objet sérialisées concernant l'exception levée.
- context
- StreamingContext
StreamingContext qui contient des informations contextuelles relatives à la source ou à la destination.
- Attributs
Exceptions
Le paramètre info
a la valeur null
.
Exemples
Le code suivant montre l’utilisation de la GetObjectData méthode pour afficher l’état d’autorisation contenu dans l’objet 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
Remarques
GetObjectData
définit un SerializationInfo avec toutes les données d'objet exception ciblées pour la sérialisation. Lors de la désérialisation, l'exception est reconstituée à partir de SerializationInfo
transmis sur le flux.