CryptographicException Constructeurs

Définition

Initialise une nouvelle instance de la classe CryptographicException.

Surcharges

CryptographicException()

Initialise une nouvelle instance de la classe CryptographicException avec des propriétés par défaut.

CryptographicException(Int32)

Initialise une nouvelle instance de la classe CryptographicException avec le code d'erreur HRESULT spécifié.

CryptographicException(String)

Initialise une nouvelle instance de la classe CryptographicException avec un message d'erreur spécifié.

CryptographicException(SerializationInfo, StreamingContext)
Obsolète.

Initialise une nouvelle instance de la classe CryptographicException avec des données sérialisées.

CryptographicException(String, Exception)

Initialise une nouvelle instance de la classe CryptographicException avec un message d'erreur spécifié et une référence à l'exception interne ayant provoqué cette exception.

CryptographicException(String, String)

Initialise une nouvelle instance de la classe CryptographicException avec un message d'erreur spécifié au format indiqué.

CryptographicException()

Source:
CryptographicException.cs
Source:
CryptographicException.cs
Source:
CryptographicException.cs

Initialise une nouvelle instance de la classe CryptographicException avec des propriétés par défaut.

public:
 CryptographicException();
public CryptographicException ();
Public Sub New ()

Exemples

L’exemple de code suivant montre comment construire un CryptographicException sans paramètre. Cet exemple de code fait partie d’un exemple plus grand fourni pour la CryptographicException classe .

CryptographicException^ cryptographicException = gcnew CryptographicException;
CryptographicException cryptographicException =
    new CryptographicException();
Dim cryptographicException As New CryptographicException

Remarques

Le tableau suivant affiche les valeurs de propriété initiales pour une instance de CryptographicException.

Propriété Valeur
InnerException null.
Message Chaîne du message d'erreur localisé.

S’applique à

CryptographicException(Int32)

Source:
CryptographicException.cs
Source:
CryptographicException.cs
Source:
CryptographicException.cs

Initialise une nouvelle instance de la classe CryptographicException avec le code d'erreur HRESULT spécifié.

public:
 CryptographicException(int hr);
public CryptographicException (int hr);
new System.Security.Cryptography.CryptographicException : int -> System.Security.Cryptography.CryptographicException
Public Sub New (hr As Integer)

Paramètres

hr
Int32

Code d'erreur HRESULT.

Exemples

L’exemple de code suivant montre comment construire un CryptographicException à l’aide d’un code d’erreur pour un CryptographicUnexpectedOperationException. Cet exemple de code fait partie d’un exemple plus grand fourni pour la CryptographicException classe .

int exceptionNumber = (int)0x80131431;
CryptographicException^ cryptographicException = gcnew CryptographicException( exceptionNumber );
int exceptionNumber = unchecked((int)0x80131431);
CryptographicException cryptographicException =
    new CryptographicException(exceptionNumber);
Dim exceptionNumber As Integer = &H80131431
Dim cryptographicException As _
    New CryptographicException(exceptionNumber)

Remarques

Le CryptographicException constructeur accepte un code d’erreur système HRESULT et définit la Message propriété sur un message localisé qui correspond à .HRESULT

Le tableau suivant affiche les valeurs de propriété initiales pour une instance de CryptographicException.

Propriété Valeur
InnerException null.
Message Chaîne du message d'erreur localisé.

S’applique à

CryptographicException(String)

Source:
CryptographicException.cs
Source:
CryptographicException.cs
Source:
CryptographicException.cs

Initialise une nouvelle instance de la classe CryptographicException avec un message d'erreur spécifié.

public:
 CryptographicException(System::String ^ message);
public CryptographicException (string? message);
public CryptographicException (string message);
new System.Security.Cryptography.CryptographicException : string -> System.Security.Cryptography.CryptographicException
Public Sub New (message As String)

Paramètres

message
String

Message d'erreur qui explique la raison de l'exception.

Exemples

L’exemple de code suivant montre comment construire un CryptographicException à l’aide d’un message d’erreur personnalisé. Cet exemple de code fait partie d’un exemple plus grand fourni pour la CryptographicException classe .

String^ errorMessage = (L"Unexpected Operation exception.");
CryptographicException^ cryptographicException = gcnew CryptographicException( errorMessage );
string errorMessage = ("Unexpected Operation exception.");
CryptographicException cryptographicException =
    new CryptographicException(errorMessage);
Dim errorMessage As String = "Unexpected Operation exception."
Dim cryptographicException As New CryptographicException(errorMessage)

Remarques

Le tableau suivant affiche les valeurs de propriété initiales pour une instance de CryptographicException.

Propriété Valeur
InnerException null.
Message Chaîne du message d'erreur.

S’applique à

CryptographicException(SerializationInfo, StreamingContext)

Source:
CryptographicException.cs
Source:
CryptographicException.cs
Source:
CryptographicException.cs

Attention

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

Initialise une nouvelle instance de la classe CryptographicException avec des données sérialisées.

protected:
 CryptographicException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected CryptographicException (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}")]
protected CryptographicException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Security.Cryptography.CryptographicException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Cryptography.CryptographicException
[<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}")>]
new System.Security.Cryptography.CryptographicException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Cryptography.CryptographicException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Paramètres

info
SerializationInfo

Objet qui contient les données sérialisées de l'objet.

context
StreamingContext

Informations contextuelles sur la source ou la destination.

Attributs

Remarques

Ce constructeur est appelé lors de la désérialisation afin de reconstituer l'objet exception transmis sur un flux.

S’applique à

CryptographicException(String, Exception)

Source:
CryptographicException.cs
Source:
CryptographicException.cs
Source:
CryptographicException.cs

Initialise une nouvelle instance de la classe CryptographicException avec un message d'erreur spécifié et une référence à l'exception interne ayant provoqué cette exception.

public:
 CryptographicException(System::String ^ message, Exception ^ inner);
public CryptographicException (string? message, Exception? inner);
public CryptographicException (string message, Exception inner);
new System.Security.Cryptography.CryptographicException : string * Exception -> System.Security.Cryptography.CryptographicException
Public Sub New (message As String, inner As Exception)

Paramètres

message
String

Message d'erreur qui explique la raison de l'exception.

inner
Exception

Exception ayant provoqué l'exception actuelle. Si le paramètre inner n'est pas null, l'exception actuelle est levée dans un bloc catch qui gère l'exception interne.

Exemples

L’exemple de code suivant montre comment construire un CryptographicException à l’aide d’un message d’erreur personnalisé et d’une exception interne. Cet exemple de code fait partie d’un exemple plus grand fourni pour la CryptographicException classe .

String^ errorMessage = (L"The current operation is not supported.");
NullReferenceException^ nullException = gcnew NullReferenceException;
CryptographicException^ cryptographicException = gcnew CryptographicException( errorMessage,nullException );
string errorMessage = ("The current operation is not supported.");
NullReferenceException nullException = new NullReferenceException();
CryptographicException cryptographicException = 
    new CryptographicException(errorMessage, nullException);
Dim errorMessage As String = "The current operation is not supported."
Dim nullException As New NullReferenceException
Dim cryptographicException As _
    New CryptographicException(errorMessage, nullException)

Remarques

Une exception levée en conséquence directe d'une exception précédente doit contenir une référence à celle-ci dans la propriété InnerException. La propriété InnerException retourne la valeur passée au constructeur ou la valeur null si la propriété InnerException ne fournit pas la valeur d'exception interne au constructeur.

Le tableau suivant affiche les valeurs de propriété initiales pour une instance de CryptographicException.

Propriété Value
InnerException La référence à l'exception interne.
Message Chaîne du message d'erreur.

Voir aussi

S’applique à

CryptographicException(String, String)

Source:
CryptographicException.cs
Source:
CryptographicException.cs
Source:
CryptographicException.cs

Initialise une nouvelle instance de la classe CryptographicException avec un message d'erreur spécifié au format indiqué.

public:
 CryptographicException(System::String ^ format, System::String ^ insert);
public CryptographicException (string format, string? insert);
public CryptographicException (string format, string insert);
new System.Security.Cryptography.CryptographicException : string * string -> System.Security.Cryptography.CryptographicException
Public Sub New (format As String, insert As String)

Paramètres

format
String

Format utilisé pour exporter le message d'erreur.

insert
String

Message d'erreur qui explique la raison de l'exception.

Exemples

L’exemple de code suivant montre comment construire un à l’aide d’un CryptographicException format d’heure et de la date actuelle. Cet exemple de code fait partie d’un exemple plus grand fourni pour la CryptographicException classe .

String^ dateFormat = L"{0:t}";
String^ timeStamp = (DateTime::Now.ToString());
CryptographicException^ cryptographicException = gcnew CryptographicException( dateFormat,timeStamp );
string dateFormat = "{0:t}";
string timeStamp = (DateTime.Now.ToString());
CryptographicException cryptographicException = 
    new CryptographicException(dateFormat, timeStamp);
Dim dateFormat As String = "{0:t}"
Dim timeStamp As String = DateTime.Now.ToString()
Dim cryptographicException As _
    New CryptographicException(dateFormat, timeStamp)

Remarques

Le tableau suivant affiche les valeurs de propriété initiales pour une instance de CryptographicException.

Propriété Valeur
InnerException null.
Message Chaîne du message d'erreur.

S’applique à