Mono Class Library: System NamespaceSystem.ObjectDisposedException Class |
See Also: ObjectDisposedException Members
System.Object
System.Exception
System.SystemException
System.InvalidOperationException
System.ObjectDisposedException
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
Note: For additional information about disposing objects, see the IDisposable interface.[Edit]
The following example demonstrates an error that causes the ObjectDisposedException exception to be thrown.
C# Example 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); } } }The output is
Caught: Cannot access a closed Stream.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0