COMException 构造函数
定义
初始化 COMException 类的新实例。Initializes a new instance of the COMException class.
重载
| COMException() |
使用默认值初始化 COMException 类的新实例。Initializes a new instance of the COMException class with default values. |
| COMException(String) |
用指定的消息初始化 COMException 类的新实例。Initializes a new instance of the COMException class with a specified message. |
| COMException(SerializationInfo, StreamingContext) |
从序列化数据初始化 COMException 类的新实例。Initializes a new instance of the COMException class from serialization data. |
| COMException(String, Exception) |
使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 COMException 类的新实例。Initializes a new instance of the COMException class with a specified error message and a reference to the inner exception that is the cause of this exception. |
| COMException(String, Int32) |
使用指定的消息和错误代码初始化 COMException 类的新实例。Initializes a new instance of the COMException class with a specified message and error code. |
COMException()
使用默认值初始化 COMException 类的新实例。Initializes a new instance of the COMException class with default values.
public:
COMException();
public COMException ();
Public Sub New ()
注解
COMException 从 ExternalException 继承。COMException inherits from ExternalException. 下表显示了此构造函数如何设置对象的属性 Exception 。The following table shows how this constructor sets the properties of the Exception object.
| PropertyProperty | 值Value |
|---|---|
| InnerException | null.null. |
| Message | 已本地化的错误消息字符串。A localized error message string. |
适用于
COMException(String)
用指定的消息初始化 COMException 类的新实例。Initializes a new instance of the COMException class with a specified message.
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
指示异常原因的消息。The message that indicates the reason for the exception.
注解
COMException 从 ExternalException 继承。COMException inherits from ExternalException. 下表显示了此构造函数如何设置对象的属性 Exception 。The following table shows how this constructor sets the properties of the Exception object.
| PropertyProperty | “值”Value |
|---|---|
| InnerException | null |
| Message | message |
适用于
COMException(SerializationInfo, StreamingContext)
从序列化数据初始化 COMException 类的新实例。Initializes a new instance of the COMException class from serialization data.
protected:
COMException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected COMException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
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 对象。The SerializationInfo object that holds the serialized object data.
- context
- StreamingContext
提供有关源或目标的上下文信息的 StreamingContext 对象。The StreamingContext object that supplies the contextual information about the source or destination.
例外
info 为 null。info is null.
注解
在反序列化期间调用此构造函数以重新构造在流上传输的异常对象。This constructor is called during deserialization to reconstitute the exception object transmitted over a stream. 有关详细信息,请参阅 XML 和 SOAP 序列化。For more information, see XML and SOAP Serialization.
COMException 从 ExternalException 继承。COMException inherits from ExternalException.
另请参阅
适用于
COMException(String, Exception)
使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 COMException 类的新实例。Initializes a new instance of the COMException class with a specified error message and a reference to the inner exception that is the cause of this exception.
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
解释异常原因的错误消息。The error message that explains the reason for the exception.
- inner
- 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.
注解
因前一个异常而直接引发的异常应在 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 属性将返回传递给构造函数的同一值;如果 InnerException 属性不向构造函数提供内部异常值,则返回 null。The 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.
下表显示了此构造函数如何设置对象的属性 Exception 。The following table shows how this constructor sets the properties of the Exception object.
| PropertyProperty | “值”Value |
|---|---|
| InnerException | 内部异常引用。The inner exception reference. |
| Message | 错误消息字符串。The error message string. |
另请参阅
适用于
COMException(String, Int32)
使用指定的消息和错误代码初始化 COMException 类的新实例。Initializes a new instance of the COMException class with a specified message and error code.
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
指示所发生异常的原因的消息。The message that indicates the reason the exception occurred.
- errorCode
- Int32
与此异常关联的错误代码 (HRESULT) 值。The error code (HRESULT) value associated with this exception.
注解
此 COMException 构造函数将基准消息设置为错误代码。This COMException constructor sets the base message with the error code.
COMException 从 ExternalException 继承。COMException inherits from ExternalException. 下表显示了此构造函数如何设置对象的属性 Exception 。The following table shows how this constructor sets the properties of the Exception object.
| PropertyProperty | “值”Value |
|---|---|
| InnerException | null |
| Message | message |