ObjectDisposedException 构造函数

定义

初始化 ObjectDisposedException 类的新实例。Initializes a new instance of the ObjectDisposedException class.

重载

ObjectDisposedException(String)

使用包含已释放对象名称的字符串初始化 ObjectDisposedException 类的新实例。Initializes a new instance of the ObjectDisposedException class with a string containing the name of the disposed object.

ObjectDisposedException(SerializationInfo, StreamingContext)

使用序列化数据初始化 ObjectDisposedException 类的新实例。Initializes a new instance of the ObjectDisposedException class with serialized data.

ObjectDisposedException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 ObjectDisposedException 类的新实例。Initializes a new instance of the ObjectDisposedException class with a specified error message and a reference to the inner exception that is the cause of this exception.

ObjectDisposedException(String, String)

使用指定的对象名称和消息初始化 ObjectDisposedException 类的新实例。Initializes a new instance of the ObjectDisposedException class with the specified object name and message.

ObjectDisposedException(String)

使用包含已释放对象名称的字符串初始化 ObjectDisposedException 类的新实例。Initializes a new instance of the ObjectDisposedException class with a string containing the name of the disposed object.

public:
 ObjectDisposedException(System::String ^ objectName);
public ObjectDisposedException (string objectName);
new ObjectDisposedException : string -> ObjectDisposedException
Public Sub New (objectName As String)

参数

objectName
String

包含已释放对象的名称的字符串。A string containing the name of the disposed object.

注解

Message 属性被初始化为系统提供的消息,该消息描述错误并包括 objectName 参数。The Message property is initialized to a system-supplied message that describes the error and includes the objectName parameter. 此消息会考虑当前系统区域性。This message takes into account the current system culture.

新实例的 InnerException 属性初始化为 nullThe InnerException property of the new instance is initialized to null.

如果 null``objectName,则 Message 属性只包含一条错误消息。If objectName is null, the Message property contains only an error message.

ObjectDisposedException(SerializationInfo, StreamingContext)

使用序列化数据初始化 ObjectDisposedException 类的新实例。Initializes a new instance of the ObjectDisposedException class with serialized data.

protected:
 ObjectDisposedException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ObjectDisposedException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new ObjectDisposedException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ObjectDisposedException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo

包含有关所引发异常的序列化对象数据的 SerializationInfoThe SerializationInfo that holds the serialized object data about the exception being thrown.

context
StreamingContext

包含有关源或目标的上下文信息的 StreamingContextThe StreamingContext that contains contextual information about the source or destination.

ObjectDisposedException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 ObjectDisposedException 类的新实例。Initializes a new instance of the ObjectDisposedException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public:
 ObjectDisposedException(System::String ^ message, Exception ^ innerException);
public ObjectDisposedException (string message, Exception innerException);
new ObjectDisposedException : string * Exception -> ObjectDisposedException
Public Sub New (message As String, innerException As Exception)

参数

message
String

用于解释异常原因的错误消息。The error message that explains the reason for the exception.

innerException
Exception

引起当前异常的异常。The exception that is the cause of the current exception. 如果 innerException 不为 null,则在处理内部异常的 catch 块中引发当前异常。If innerException 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 属性返回传递到构造函数中的相同值。The InnerException property returns the same value that is passed into the constructor.

ObjectDisposedException(String, String)

使用指定的对象名称和消息初始化 ObjectDisposedException 类的新实例。Initializes a new instance of the ObjectDisposedException class with the specified object name and message.

public:
 ObjectDisposedException(System::String ^ objectName, System::String ^ message);
public ObjectDisposedException (string objectName, string message);
new ObjectDisposedException : string * string -> ObjectDisposedException
Public Sub New (objectName As String, message As String)

参数

objectName
String

已释放的对象名。The name of the disposed object.

message
String

用于解释异常原因的错误消息。The error message that explains the reason for the exception.

注解

新实例的 InnerException 属性初始化为 nullThe InnerException property of the new instance is initialized to null.

如果 null``objectName,则 Message 属性只包含一条错误消息。If objectName is null, the Message property contains only an error message.

适用于