語言

COMException 建構函式

定義

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

多載

名稱 Description
COMException()

初始化一個以預設值的新類別實例 COMException 。

COMException(String)

使用指定的訊息,初始化 COMException 類別的新實例。

COMException(SerializationInfo, StreamingContext)
已淘汰.

從序列化資料初始化該類別的新實例 COMException 。

COMException(String, Exception)

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

COMException(String, Int32)

初始化類別的新實例 COMException ,並以指定的訊息與錯誤代碼。

COMException()

來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs

初始化一個以預設值的新類別實例 COMException 。

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

備註

COMException 繼承自 ExternalException。 下表展示了此建構器如何設定物件的 Exception 屬性。

房產 價值觀
InnerException null。
Message 一個局部錯誤訊息字串。

適用於

COMException(String)

來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs

使用指定的訊息,初始化 COMException 類別的新實例。

public:
 COMException(System::String ^ message);
public COMException(string message);
public COMException(string? message);
new System.Runtime.InteropServices.COMException : string -> System.Runtime.InteropServices.COMException
Public Sub New (message As String)

參數

message
String

說明例外原因的訊息。

備註

COMException 繼承自 ExternalException。 下表展示了此建構器如何設定物件的 Exception 屬性。

房產 價值觀
InnerException null
Message message

適用於

COMException(SerializationInfo, StreamingContext)

來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs

警告

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

從序列化資料初始化該類別的新實例 COMException 。

protected:
 COMException(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 COMException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected COMException(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.Runtime.InteropServices.COMException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Runtime.InteropServices.COMException
new System.Runtime.InteropServices.COMException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Runtime.InteropServices.COMException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

參數

info
SerializationInfo

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

context
StreamingContext

提供 StreamingContext 來源或目的地上下文資訊的物件。

屬性

例外狀況

info 是 null。

備註

此建構子在反序列化過程中被呼叫,以重建透過串流傳輸的例外物件。 欲了解更多資訊,請參閱 XML 與 SOAP 序列化。

COMException 繼承自 ExternalException。

另請參閱

適用於

COMException(String, Exception)

來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs

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

public:
 COMException(System::String ^ message, Exception ^ inner);
public COMException(string message, Exception inner);
public COMException(string? message, Exception? inner);
new System.Runtime.InteropServices.COMException : string * Exception -> System.Runtime.InteropServices.COMException
Public Sub New (message As String, inner As Exception)

參數

message
String

說明例外狀況原因的錯誤訊息。

inner
Exception

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

備註

因先前例外直接拋出的例外,應包含對該屬性中 InnerException 先前例外的參考。 該 InnerException 屬性回傳與傳入建構子相同的值,或 null 若該 InnerException 性質未提供內部例外值給建構子。

下表展示了此建構器如何設定物件的 Exception 屬性。

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

另請參閱

適用於

COMException(String, Int32)

來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs
來源:
COMException.cs

初始化類別的新實例 COMException ,並以指定的訊息與錯誤代碼。

public:
 COMException(System::String ^ message, int errorCode);
public COMException(string message, int errorCode);
public COMException(string? message, int errorCode);
new System.Runtime.InteropServices.COMException : string * int -> System.Runtime.InteropServices.COMException
Public Sub New (message As String, errorCode As Integer)

參數

message
String

說明異常發生原因的訊息。

errorCode
Int32

與此例外相關的錯誤代碼(HRESULT)值。

備註

此 COMException 建構器會將基礎訊息與錯誤碼一起設定。

COMException 繼承自 ExternalException。 下表展示了此建構器如何設定物件的 Exception 屬性。

房產 價值觀
InnerException null
Message message

適用於