TargetException 构造函数

定义

初始化 TargetException 类的新实例。

重载

TargetException()

使用空消息和异常的根本原因初始化 TargetException 类的新实例。

TargetException(String)

使用给定消息和根源异常初始化 TargetException 类的新实例。

TargetException(SerializationInfo, StreamingContext)
已过时.

使用指定的序列化和上下文信息初始化 TargetException 类的新实例。

TargetException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 TargetException 类的新实例。

TargetException()

Source:
TargetException.cs
Source:
TargetException.cs
Source:
TargetException.cs

使用空消息和异常的根本原因初始化 TargetException 类的新实例。

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

注解

属性 InnerException 设置为 null ,HRESULT 错误代码设置为 COR_E_TARGET。

TargetException 继承自 Exception。 此构造函数设置 对象的属性 Exception ,如下表所示。

properties Value
InnerException null
Message 空字符串 (“”) 。

适用于

TargetException(String)

Source:
TargetException.cs
Source:
TargetException.cs
Source:
TargetException.cs

使用给定消息和根源异常初始化 TargetException 类的新实例。

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

注解

TargetException 继承自 Exception。 此构造函数设置 对象的属性 Exception ,如下表所示。

properties
InnerException null
Message message 字符串。

适用于

TargetException(SerializationInfo, StreamingContext)

Source:
TargetException.cs
Source:
TargetException.cs
Source:
TargetException.cs

注意

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

使用指定的序列化和上下文信息初始化 TargetException 类的新实例。

protected:
 TargetException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected TargetException (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 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
[<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.Reflection.TargetException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Reflection.TargetException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo

用于串行化或反序列化对象的数据。

context
StreamingContext

对象的源和目标。

属性

适用于

TargetException(String, Exception)

Source:
TargetException.cs
Source:
TargetException.cs
Source:
TargetException.cs

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 TargetException 类的新实例。

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

解释异常原因的错误消息。

inner
Exception

导致当前异常的异常。 如果 inner 参数不为 null,则当前异常将在处理内部异常的 catch 块中引发。

注解

因前一个异常而直接引发的异常应在 InnerException 属性中包含对前一个异常的引用。 InnerException 属性将返回传递给构造函数的同一值;如果 InnerException 属性不向构造函数提供内部异常值,则返回 null

下表显示了 TargetException 实例的初始属性值。

properties “值”
InnerException 内部异常引用。
Message 错误消息字符串。

另请参阅

适用于