TargetException 构造函数
定义
初始化 TargetException 类的新实例。Initializes a new instance of the TargetException class.
重载
| TargetException() |
使用空消息和异常的根本原因初始化 TargetException 类的新实例。Initializes a new instance of the TargetException class with an empty message and the root cause of the exception. |
| TargetException(String) |
使用给定消息和根源异常初始化 TargetException 类的新实例。Initializes a new instance of the TargetException class with the given message and the root cause exception. |
| TargetException(SerializationInfo, StreamingContext) |
使用指定的序列化和上下文信息初始化 TargetException 类的新实例。Initializes a new instance of the TargetException class with the specified serialization and context information. |
| TargetException(String, Exception) |
使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 TargetException 类的新实例。Initializes a new instance of the TargetException class with a specified error message and a reference to the inner exception that is the cause of this exception. |
TargetException()
使用空消息和异常的根本原因初始化 TargetException 类的新实例。Initializes a new instance of the TargetException class with an empty message and the root cause of the exception.
public:
TargetException();
public TargetException ();
Public Sub New ()
注解
InnerException属性设置为 null ,并且 HRESULT 错误代码设置为 COR_E_TARGET。The InnerException property is set to null and the HRESULT error code is set to COR_E_TARGET.
TargetException 继承自 Exception 。TargetException inherits from the Exception. 此构造函数将设置对象的属性,如下 Exception 表所示。This constructor sets the properties of the Exception object as shown in the following table.
| propertiesProperty | ValueValue |
|---|---|
| InnerException | null |
| Message | 空字符串 ( "" ) 。The empty string (""). |
适用于
TargetException(String)
使用给定消息和根源异常初始化 TargetException 类的新实例。Initializes a new instance of the TargetException class with the given message and the root cause exception.
public:
TargetException(System::String ^ message);
public TargetException (string? message);
public TargetException (string message);
new System.Reflection.TargetException : string -> System.Reflection.TargetException
Public Sub New (message As String)
参数
- message
- String
描述异常发生原因的 String。A String describing the reason why the exception occurred.
注解
TargetException 继承自 Exception 。TargetException inherits from the Exception. 此构造函数将设置对象的属性,如下 Exception 表所示。This constructor sets the properties of the Exception object as shown in the following table.
| propertiesProperty | 值Value |
|---|---|
| InnerException | null |
| Message | message 字符串。The message string. |
适用于
TargetException(SerializationInfo, StreamingContext)
使用指定的序列化和上下文信息初始化 TargetException 类的新实例。Initializes a new instance of the TargetException class with the specified serialization and context information.
protected:
TargetException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected TargetException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Reflection.TargetException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Reflection.TargetException
Protected Sub New (info As SerializationInfo, context As StreamingContext)
参数
- info
- SerializationInfo
用于串行化或反序列化对象的数据。The data for serializing or deserializing the object.
- context
- StreamingContext
对象的源和目标。The source of and destination for the object.
适用于
TargetException(String, Exception)
使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 TargetException 类的新实例。Initializes a new instance of the TargetException class with a specified error message and a reference to the inner exception that is the cause of this exception.
public:
TargetException(System::String ^ message, Exception ^ inner);
public TargetException (string? message, Exception? inner);
public TargetException (string message, Exception inner);
new System.Reflection.TargetException : string * Exception -> System.Reflection.TargetException
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.
下表显示了 TargetException 实例的初始属性值。The following table shows the initial property values for an instance of TargetException.
| PropertyProperty | “值”Value |
|---|---|
| InnerException | 内部异常引用。The inner exception reference. |
| Message | 错误消息字符串。The error message string. |