COMException 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 COMException 类的新实例。
重载
| 名称 | 说明 |
|---|---|
| COMException() |
使用默认值初始化 COMException 类的新实例。 |
| COMException(String) |
使用指定的消息初始化类的新实例 COMException 。 |
| COMException(SerializationInfo, StreamingContext) |
已过时.
从序列化数据初始化类的新实例 COMException 。 |
| COMException(String, Exception) |
使用指定的错误消息和对作为此异常原因的内部异常的引用初始化类的新实例 COMException 。 |
| COMException(String, Int32) |
使用指定的消息和错误代码初始化类的新实例 COMException 。 |
COMException()
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
使用默认值初始化 COMException 类的新实例。
public:
COMException();
public COMException();
Public Sub New ()
注解
COMException 继承自 ExternalException. 下表显示了此构造函数如何设置对象的属性 Exception 。
| 财产 | 价值 |
|---|---|
| InnerException |
null。 |
| Message | 本地化的错误消息字符串。 |
适用于
COMException(String)
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- 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)
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- 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)
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- 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)
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- COMException.cs
- Source:
- 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 |