<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>
    <summary>
      <para> Represents the error that occurs when an operation is
      performed on a disposed object.</para>
    </summary>
    <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>
  </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>
        <param name="objectName">A <see cref="T:System.String" /> containing the name of the disposed object.</param>
        <summary>
          <para>Constructs and initializes a new instance of the <see cref="T:System.ObjectDisposedException" /> class.</para>
        </summary>
        <remarks>
          <para>This constructor initializes the <see cref="P:System.ObjectDisposedException.ObjectName" /> property of the new instance
   using <paramref name="objectName. " /> The <see cref="P:System.ObjectDisposedException.Message" /> property is initialized to a system-supplied message that describes the
   error<paramref name=" " />and
   includes <paramref name="objectname" /> . This message takes into account the
   current system culture. </para>
          <para>The <see cref="!:System.ObjectDisposedException.InnerException" /> property of the new instance is
initialized to <see langword="null" />.</para>
          <para>
            <block subset="none" type="note">If <paramref name="objectName" /> is
<see langword="null" />, the <see cref="P:System.ObjectDisposedException.Message" /> property 
contains only an error message.</block>
          </para>
        </remarks>
        <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>
      </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>
        <param name="info">To be added.</param>
        <param name="context">To be added.</param>
        <summary>To be added.</summary>
        <remarks>To be added.</remarks>
      </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>
        <param name="message">To be added.</param>
        <param name="innerException">To be added.</param>
        <summary>To be added.</summary>
        <remarks>To be added.</remarks>
        <since version=".NET 2.0" />
      </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>
        <param name="objectName">A <see cref="T:System.String" /> containing the name of the disposed object.</param>
        <param name="message">A <see cref="T:System.String" /> that describes the error. The content of <paramref name="message" /> is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.</param>
        <param name="message">To be added.</param>
        <summary>
          <para>Constructs and initializes a new instance of the <see cref="T:System.ObjectDisposedException" /> class.</para>
        </summary>
        <remarks>
          <para>This constructor initializes the <see cref="P:System.ObjectDisposedException.Message" /> property of the new instance
   using <paramref name="message" />, and the <see cref="P:System.ObjectDisposedException.ObjectName" /> property using
<paramref name="objectName" /> . If <paramref name="message" /> is 
<see langword="null" />, the <see cref="P:System.ObjectDisposedException.Message" /> property is initialized to the system-supplied message 
   provided by the constructor that takes no arguments.</para>
          <para>The <see cref="!:System.ObjectDisposedException.InnerException" /> property of the new instance is
initialized to <see langword="null" />.</para>
        </remarks>
        <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>
      </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>
        <param name="info">To be added.</param>
        <param name="context">To be added.</param>
        <summary>To be added.</summary>
        <remarks>To be added.</remarks>
      </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>
        <summary>
          <para> Gets the message that describes the error.</para>
        </summary>
        <value>
          <para>A <see cref="T:System.String" /> that describes
   the error. </para>
        </value>
        <remarks>
          <para>If the <see cref="P:System.ObjectDisposedException.ObjectName" /> property is not
<see langword="null" /> 
, the message includes the name of the object. </para>
          <para>This property is read-only.</para>
          <para>
            <block subset="none" type="note">This property overrides <see cref="P:System.Exception.Message" />.</block>
          </para>
        </remarks>
      </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>
        <summary>
          <para>Gets the name of the disposed object.</para>
        </summary>
        <value>
          <para>A <see cref="T:System.String" /> containing the name of the disposed object.</para>
        </value>
        <remarks>
          <para>
            <block subset="none" type="note">If this property is not <see langword="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. </block>
          </para>
          <para> This property is read-only.</para>
        </remarks>
      </Docs>
      <Excluded>0</Excluded>
    </Member>
  </Members>
  <TypeExcluded>0</TypeExcluded>
</Type>
