CryptographicException CryptographicException CryptographicException CryptographicException Constructors

定义

重载

CryptographicException() CryptographicException() CryptographicException()

使用默认属性初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with default properties.

CryptographicException(Int32) CryptographicException(Int32) CryptographicException(Int32) CryptographicException(Int32)

用指定的 HRESULT 错误代码初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with the specified HRESULT error code.

CryptographicException(String) CryptographicException(String) CryptographicException(String) CryptographicException(String)

用指定的错误消息初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with a specified error message.

CryptographicException(SerializationInfo, StreamingContext) CryptographicException(SerializationInfo, StreamingContext) CryptographicException(SerializationInfo, StreamingContext) CryptographicException(SerializationInfo, StreamingContext)

用序列化数据初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with serialized data.

CryptographicException(String, Exception) CryptographicException(String, Exception) CryptographicException(String, Exception) CryptographicException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with a specified error message and a reference to the inner exception that is the cause of this exception.

CryptographicException(String, String) CryptographicException(String, String) CryptographicException(String, String) CryptographicException(String, String)

以指定格式使用指定的错误消息来初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with a specified error message in the specified format.

CryptographicException() CryptographicException() CryptographicException()

使用默认属性初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with default properties.

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

示例

下面的代码示例演示如何构造CryptographicException不带任何参数。The following code example demonstrates how to construct a CryptographicException with no parameters. 此代码示例是为提供一个更大示例的一部分CryptographicException类。This code example is part of a larger example provided for the CryptographicException class.

CryptographicException^ cryptographicException = gcnew CryptographicException;

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

注解

下表显示 CryptographicException 的实例的初始属性值。The following table shows the initial property values for an instance of CryptographicException.

PropertyProperty Value
InnerException nullnull.
Message 本地化的错误消息字符串。The localized error message string.

CryptographicException(Int32) CryptographicException(Int32) CryptographicException(Int32) CryptographicException(Int32)

用指定的 HRESULT 错误代码初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with the specified HRESULT error code.

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

参数

hr
Int32 Int32 Int32 Int32

HRESULT 错误代码。The HRESULT error code.

示例

下面的代码示例演示如何构造CryptographicException使用的错误代码CryptographicUnexpectedOperationExceptionThe following code example demonstrates how to construct a CryptographicException using an error code for an CryptographicUnexpectedOperationException. 此代码示例是为提供一个更大示例的一部分CryptographicException类。This code example is part of a larger example provided for the CryptographicException class.

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)

注解

CryptographicException构造函数接受一个系统HRESULT错误代码和集Message属性设置为与相对应的本地化消息HRESULTThe CryptographicException constructor accepts a system HRESULT error code and sets the Message property to a localized message that corresponds to the HRESULT.

下表显示 CryptographicException 的实例的初始属性值。The following table shows the initial property values for an instance of CryptographicException.

PropertyProperty Value
InnerException nullnull.
Message 本地化的错误消息字符串。The localized error message string.

CryptographicException(String) CryptographicException(String) CryptographicException(String) CryptographicException(String)

用指定的错误消息初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with a specified error message.

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

参数

message
String String String String

解释异常原因的错误消息。The error message that explains the reason for the exception.

示例

下面的代码示例演示如何构造CryptographicException使用自定义错误消息。The following code example demonstrates how to construct a CryptographicException using a custom error message. 此代码示例是为提供一个更大示例的一部分CryptographicException类。This code example is part of a larger example provided for the CryptographicException class.

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)

注解

下表显示 CryptographicException 的实例的初始属性值。The following table shows the initial property values for an instance of CryptographicException.

PropertyProperty Value
InnerException nullnull.
Message 错误消息字符串。The error message string.

CryptographicException(SerializationInfo, StreamingContext) CryptographicException(SerializationInfo, StreamingContext) CryptographicException(SerializationInfo, StreamingContext) CryptographicException(SerializationInfo, StreamingContext)

用序列化数据初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with serialized data.

protected:
 CryptographicException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
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
Protected Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo SerializationInfo SerializationInfo SerializationInfo

承载序列化对象数据的对象。The object that holds the serialized object data.

context
StreamingContext StreamingContext StreamingContext StreamingContext

关于来源和目标的上下文信息The contextual information about the source or destination.

注解

此构造函数在反序列化过程中调用,以便重建通过流传输的异常对象。This constructor is called during deserialization to reconstitute the exception object transmitted over a stream.

CryptographicException(String, Exception) CryptographicException(String, Exception) CryptographicException(String, Exception) CryptographicException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public:
 CryptographicException(System::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)

参数

message
String String String String

解释异常原因的错误消息。The error message that explains the reason for the exception.

inner
Exception Exception Exception Exception

导致当前异常的异常。The exception that is the cause of the current exception. 如果 inner 参数不为 null,则当前异常将在处理内部异常的 catch 块中引发。If the inner parameter is not null, the current exception is raised in a catch block that handles the inner exception.

示例

下面的代码示例演示如何构造CryptographicException使用自定义错误消息和内部异常。The following code example demonstrates how to construct a CryptographicException using a custom error message and an inner exception. 此代码示例是为提供一个更大示例的一部分CryptographicException类。This code example is part of a larger example provided for the CryptographicException class.

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)

注解

因前一个异常而直接引发的异常应在 InnerException 属性中包含对前一个异常的引用。An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. InnerException 属性返回的值与传递到构造函数中的值相同;或者,如果 null 属性没有向构造函数提供内部异常值,则为 InnerExceptionThe InnerException property returns the same value that is passed into the constructor, or null if the InnerException property does not supply the inner exception value to the constructor.

下表显示 CryptographicException 的实例的初始属性值。The following table shows the initial property values for an instance of CryptographicException.

PropertyProperty “值”Value
InnerException 内部异常引用。The inner exception reference.
Message 错误消息字符串。The error message string.
另请参阅

CryptographicException(String, String) CryptographicException(String, String) CryptographicException(String, String) CryptographicException(String, String)

以指定格式使用指定的错误消息来初始化 CryptographicException 类的新实例。Initializes a new instance of the CryptographicException class with a specified error message in the specified format.

public:
 CryptographicException(System::String ^ format, System::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)

参数

format
String String String String

用于输出错误信息的格式。The format used to output the error message.

insert
String String String String

解释异常原因的错误消息。The error message that explains the reason for the exception.

示例

下面的代码示例演示如何构造CryptographicException使用当前日期和时间格式。The following code example demonstrates how to construct a CryptographicException using a time format and the current date. 此代码示例是为提供一个更大示例的一部分CryptographicException类。This code example is part of a larger example provided for the CryptographicException class.

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)

注解

下表显示 CryptographicException 的实例的初始属性值。The following table shows the initial property values for an instance of CryptographicException.

PropertyProperty Value
InnerException nullnull.
Message 错误消息字符串。The error message string.

适用于