﻿<?xml version="1.0" encoding="utf-8"?><Type Name="ObjectDisposedException" FullName="System.ObjectDisposedException" FullNameSP="System_ObjectDisposedException" Maintainer="ecma"><TypeSignature Language="ILASM" Value=".class public serializable ObjectDisposedException extends System.InvalidOperationException" /><TypeSignature Language="C#" Value="public class ObjectDisposedException : InvalidOperationException" /><TypeSignature Language="ILAsm" Value=".class public auto ansi serializable beforefieldinit ObjectDisposedException extends System.InvalidOperationException" /><MemberOfLibrary>BCL</MemberOfLibrary><AssemblyInfo><AssemblyName>mscorlib</AssemblyName><AssemblyPublicKey>[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]</AssemblyPublicKey><AssemblyVersion>1.0.5000.0</AssemblyVersion><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><ThreadingSafetyStatement>All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.</ThreadingSafetyStatement><Base><BaseTypeName>System.InvalidOperationException</BaseTypeName></Base><Interfaces /><Attributes><Attribute><AttributeName>System.Runtime.InteropServices.ComVisible(true)</AttributeName></Attribute></Attributes><Docs><remarks><para><block subset="none" type="note">For additional information about
      disposing objects, see the <see cref="T:System.IDisposable" /> interface.</block></para></remarks><example><para>The following example demonstrates an error that causes the <see cref="T:System.ObjectDisposedException" />
exception to be thrown.</para><code lang="C#">using System;
using System.IO;

public class ObjectDisposedExceptionTest {
   public static void Main() {     
      MemoryStream ms = new MemoryStream(16);
      ms.Close();
      try {
         ms.ReadByte();
      } 
      catch (ObjectDisposedException e) {
         Console.WriteLine("Caught: {0}", e.Message);
      }
   }
}
</code><para>The output is</para><c><para>Caught: Cannot access a closed Stream.</para></c></example><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>The exception that is thrown when an operation is performed on a disposed object.</para></summary></Docs><Members><Member MemberName=".ctor"><MemberSignature Language="ILASM" Value="public rtspecialname specialname instance void .ctor(string objectName)" /><MemberSignature Language="C#" Value="public ObjectDisposedException (string objectName);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string objectName) cil managed" /><MemberType>Constructor</MemberType><AssemblyInfo><AssemblyVersion>1.0.5000.0</AssemblyVersion><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><ReturnValue /><Parameters><Parameter Name="objectName" Type="System.String" /></Parameters><Docs><example><para>The following example displays the error message of a
   <see cref="T:System.ObjectDisposedException" /> instance created
      using this constructor.</para><code lang="C#">using System;

public class ExampleDisposableObject : IDisposable {
 public static void Main() {
 
 ExampleDisposableObject obj = new ExampleDisposableObject();
 
 obj.Close();
 
 try {
 Console.WriteLine(obj);
 } catch (ObjectDisposedException e) {
 Console.WriteLine("Caught: {0}", e.Message);
 }
 }
 

 public ExampleDisposableObject() {
 isDisposed = false;
 }
 
 ~ExampleDisposableObject() {
 Dispose(true);
 }
 
 public void Close() {
 Dispose(true);
 }
 
 public void Dispose() {
 Dispose(true);
 }
 
 public void Dispose(bool disposing) {
 isDisposed = true;
 }
 
 public override String ToString() {
 if(isDisposed)
 throw new ObjectDisposedException("ExampleDisposableObject");
 else
 return "This is an instance of ExampleDisposableObject.";
 }
 
 private bool isDisposed;
}
   </code><para>The output is</para><c><para>Caught: Cannot access a disposed object named "ExampleDisposableObject".</para><para>Object name: "ExampleDisposableObject".</para></c></example><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para>The <see cref="P:System.ObjectDisposedException.Message" /> property is initialized to a system-supplied message that describes the error and includes the <paramref name="objectName" /> parameter. This message takes into account the current system culture.</para><para>The InnerException property of the new instance is initialized to null.</para><para>If <paramref name="objectName" /> is null, the Message property contains only an error message.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Initializes a new instance of the <see cref="T:System.ObjectDisposedException" /> class with a string containing the name of the disposed object.</para></summary><param name="objectName"><attribution license="cc4" from="Microsoft" modified="false" />A string containing the name of the disposed object. </param></Docs><Excluded>0</Excluded></Member><Member MemberName=".ctor"><MemberSignature Language="C#" Value="protected ObjectDisposedException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);" /><MemberSignature Language="ILAsm" Value=".method familyhidebysig specialname rtspecialname instance void .ctor(class System.Runtime.Serialization.SerializationInfo info, valuetype System.Runtime.Serialization.StreamingContext context) cil managed" /><MemberType>Constructor</MemberType><AssemblyInfo><AssemblyVersion>1.0.5000.0</AssemblyVersion><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><Parameters><Parameter Name="info" Type="System.Runtime.Serialization.SerializationInfo" /><Parameter Name="context" Type="System.Runtime.Serialization.StreamingContext" /></Parameters><Docs><remarks>To be added.</remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Initializes a new instance of the <see cref="T:System.ObjectDisposedException" /> class with serialized data.</para></summary><param name="info"><attribution license="cc4" from="Microsoft" modified="false" />The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown. </param><param name="context"><attribution license="cc4" from="Microsoft" modified="false" />The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination. </param></Docs></Member><Member MemberName=".ctor"><MemberSignature Language="C#" Value="public ObjectDisposedException (string message, Exception innerException);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string message, class System.Exception innerException) cil managed" /><MemberType>Constructor</MemberType><AssemblyInfo><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><Parameters><Parameter Name="message" Type="System.String" /><Parameter Name="innerException" Type="System.Exception" /></Parameters><Docs><since version=".NET 2.0" /><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para>An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the <see cref="P:System.Exception.InnerException" /> property. The <see cref="P:System.Exception.InnerException" /> property returns the same value that is passed into the constructor.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Initializes a new instance of the <see cref="T:System.ObjectDisposedException" /> class with a specified error message and a reference to the inner exception that is the cause of this exception.</para></summary><param name="message"><attribution license="cc4" from="Microsoft" modified="false" />The error message that explains the reason for the exception.</param><param name="innerException"><attribution license="cc4" from="Microsoft" modified="false" />The exception that is the cause of the current exception. If <paramref name="innerException" /> is not null, the current exception is raised in a catch block that handles the inner exception.</param></Docs></Member><Member MemberName=".ctor"><MemberSignature Language="ILASM" Value="public rtspecialname specialname instance void .ctor(string objectName, string message)" /><MemberSignature Language="C#" Value="public ObjectDisposedException (string objectName, string message);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string objectName, string message) cil managed" /><MemberType>Constructor</MemberType><AssemblyInfo><AssemblyVersion>1.0.5000.0</AssemblyVersion><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><ReturnValue /><Parameters><Parameter Name="objectName" Type="System.String" /><Parameter Name="message" Type="System.String" /></Parameters><Docs><example><para>The following example throws a <see cref="T:System.ObjectDisposedException" /> instance created using this
   constructor.</para><code lang="C#">using System;

public class ExampleDisposableObject : IDisposable {
 public static void Main() {
 
 ExampleDisposableObject obj = new ExampleDisposableObject();
 
 obj.Close();
 
 try {
 Console.WriteLine(obj);
 } catch (ObjectDisposedException e) {
 Console.WriteLine("Caught: {0}", e.Message);
 }
 }
 

 public ExampleDisposableObject() {
 isDisposed = false;
 }
 
 ~ExampleDisposableObject() {
 Dispose(true);
 }
 
 public void Close() {
 Dispose(true);
 }
 
 public void Dispose() {
 Dispose(true);
 }
 
 public void Dispose(bool disposing) {
 isDisposed = true;
 }
 
 public override String ToString() {
 if(isDisposed) {
 string message = "Oh-oh! This object has been disposed!";
 string objectName = "ExampleDisposableObject"; 
 throw new ObjectDisposedException(objectName, message);
 }
 else
 return "Hello, World!";
 }
 
 private bool isDisposed;
}
</code><para>The output is</para><c><para>Caught: Oh-oh! This object has been disposed!</para><para>Object name: "ExampleDisposableObject".</para></c></example><param name="message"><attribution license="cc4" from="Microsoft" modified="false" />The error message that explains the reason for the exception. </param><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para>The InnerException property of the new instance is initialized to null.</para><para>If <paramref name="objectName" /> is null, the Message property contains only an error message.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Initializes a new instance of the <see cref="T:System.ObjectDisposedException" /> class with the specified object name and message.</para></summary><param name="objectName"><attribution license="cc4" from="Microsoft" modified="false" />The name of the disposed object. </param><param name="message"><attribution license="cc4" from="Microsoft" modified="false" />The error message that explains the reason for the exception. </param></Docs><Excluded>0</Excluded></Member><Member MemberName="GetObjectData"><MemberSignature Language="C#" Value="public override void GetObjectData (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance void GetObjectData(class System.Runtime.Serialization.SerializationInfo info, valuetype System.Runtime.Serialization.StreamingContext context) cil managed" /><MemberType>Method</MemberType><AssemblyInfo><AssemblyVersion>1.0.5000.0</AssemblyVersion><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>System.Void</ReturnType></ReturnValue><Parameters><Parameter Name="info" Type="System.Runtime.Serialization.SerializationInfo" /><Parameter Name="context" Type="System.Runtime.Serialization.StreamingContext" /></Parameters><Docs><remarks>To be added.</remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Retrieves the <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object with the parameter name and additional exception information.</para></summary><param name="info"><attribution license="cc4" from="Microsoft" modified="false" />The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown. </param><param name="context"><attribution license="cc4" from="Microsoft" modified="false" />The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination. </param></Docs></Member><Member MemberName="Message"><MemberSignature Language="ILASM" Value=".property string Message { public hidebysig virtual specialname string get_Message() }" /><MemberSignature Language="C#" Value="public override string Message { get; }" /><MemberSignature Language="ILAsm" Value=".property instance string Message" /><MemberType>Property</MemberType><AssemblyInfo><AssemblyVersion>1.0.5000.0</AssemblyVersion><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>System.String</ReturnType></ReturnValue><Parameters /><Docs><value><para>A <see cref="T:System.String" /> that describes
   the error. </para></value><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para>If the <see cref="P:System.ObjectDisposedException.ObjectName" /> property is not null, the message includes the name of the object.</para><para>This property overrides <see cref="P:System.Exception.Message" />.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Gets the message that describes the error.</para></summary></Docs><Excluded>0</Excluded></Member><Member MemberName="ObjectName"><MemberSignature Language="ILASM" Value=".property string ObjectName { public hidebysig specialname instance string get_ObjectName() }" /><MemberSignature Language="C#" Value="public string ObjectName { get; }" /><MemberSignature Language="ILAsm" Value=".property instance string ObjectName" /><MemberType>Property</MemberType><AssemblyInfo><AssemblyVersion>1.0.5000.0</AssemblyVersion><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>System.String</ReturnType></ReturnValue><Parameters /><Docs><value><para>A <see cref="T:System.String" /> containing the name of the disposed object.</para></value><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para>If the current property is not null or <see cref="F:System.String.Empty" />, the value of this property is included in the string returned by the <see cref="P:System.ObjectDisposedException.Message" /> property.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Gets the name of the disposed object.</para></summary></Docs><Excluded>0</Excluded></Member></Members><TypeExcluded>0</TypeExcluded></Type>