共用方式為


CryptographicException 建構函式

定義

初始化 CryptographicException 類別的新執行個體。

多載

名稱 Description
CryptographicException()

初始化一個帶有預設屬性的新 CryptographicException 類別實例。

CryptographicException(Int32)

初始化類別的新實例 CryptographicException ,並使用指定的 HRESULT 錯誤碼。

CryptographicException(String)

初始化類別的新實例 CryptographicException 並指定錯誤訊息。

CryptographicException(SerializationInfo, StreamingContext)
已淘汰.

初始化一個新的類別實例 CryptographicException ,並使用序列化資料。

CryptographicException(String, Exception)

初始化類別的新實例 CryptographicException ,並附上指定的錯誤訊息及導致該異常的內部例外的參考。

CryptographicException(String, String)

初始化類別的新實例 CryptographicException ,並以指定格式發出錯誤訊息。

CryptographicException()

來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs

初始化一個帶有預設屬性的新 CryptographicException 類別實例。

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

範例

以下程式碼範例示範如何在無參數的情況下構造 a CryptographicException 。 此程式碼範例是本類別更大範例 CryptographicException 的一部分。

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

備註

下表顯示了 的 CryptographicException初始屬性值。

房產 價值
InnerException null
Message 區域化錯誤訊息字串。

適用於

CryptographicException(Int32)

來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs

初始化類別的新實例 CryptographicException ,並使用指定的 HRESULT 錯誤碼。

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

錯誤 HRESULT 代碼。

範例

以下程式碼範例示範如何利用錯誤碼來CryptographicUnexpectedOperationException構造 。CryptographicException 此程式碼範例是本類別更大範例 CryptographicException 的一部分。

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

備註

CryptographicException建構子接受系統HRESULT錯誤碼,並將屬性設定Message為對應於 的HRESULT局部訊息。

下表顯示了 的 CryptographicException初始屬性值。

房產 價值
InnerException null
Message 區域化錯誤訊息字串。

適用於

CryptographicException(String)

來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs

初始化類別的新實例 CryptographicException 並指定錯誤訊息。

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)

參數

message
String

錯誤訊息解釋了例外原因。

範例

以下程式碼範例示範如何利用自訂錯誤訊息來構建 。CryptographicException 此程式碼範例是本類別更大範例 CryptographicException 的一部分。

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

備註

下表顯示了 的 CryptographicException初始屬性值。

房產 價值
InnerException null
Message 錯誤訊息字串。

適用於

CryptographicException(SerializationInfo, StreamingContext)

來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs

警告

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

初始化一個新的類別實例 CryptographicException ,並使用序列化資料。

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);
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}")>]
new System.Security.Cryptography.CryptographicException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Cryptography.CryptographicException
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

存放序列化物件資料的物件。

context
StreamingContext

關於來源或目的地的上下文資訊。

屬性

備註

此建構子在反序列化過程中被呼叫,以重建透過串流傳輸的例外物件。

適用於

CryptographicException(String, Exception)

來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs

初始化類別的新實例 CryptographicException ,並附上指定的錯誤訊息及導致該異常的內部例外的參考。

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)

參數

message
String

錯誤訊息解釋了例外原因。

inner
Exception

該例外即為當前例外的原因。 若 inner 參數不 null為 ,則在處理內部異常的區塊中提出 catch 當前例外。

範例

以下程式碼範例示範如何利用自訂錯誤訊息與內部例外來建構 。CryptographicException 此程式碼範例是本類別更大範例 CryptographicException 的一部分。

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 先前例外的參考。 該 InnerException 屬性回傳與傳入建構子相同的值,或 null 若該 InnerException 性質未提供內部例外值給建構子。

下表顯示了 的 CryptographicException初始屬性值。

房產 價值
InnerException 內部例外的參考。
Message 錯誤訊息字串。

另請參閱

適用於

CryptographicException(String, String)

來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs
來源:
CryptographicException.cs

初始化類別的新實例 CryptographicException ,並以指定格式發出錯誤訊息。

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)

參數

format
String

輸出錯誤訊息的格式。

insert
String

錯誤訊息解釋了例外原因。

範例

以下程式碼範例示範如何利用時間格式和當前日期來構造 a CryptographicException 。 此程式碼範例是本類別更大範例 CryptographicException 的一部分。

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初始屬性值。

房產 價值
InnerException null
Message 錯誤訊息字串。

適用於