1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
|
<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 : 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>
</AssemblyInfo>
<ThreadingSafetyStatement>All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.</ThreadingSafetyStatement>
<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>
<Base>
<BaseTypeName>System.InvalidOperationException</BaseTypeName>
</Base>
<Interfaces />
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="ILASM" Value="public rtspecialname specialname instance void .ctor(string objectName)" />
<MemberSignature Language="C#" Value="public ObjectDisposedException (string objectName);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="objectName" Type="System.String" />
</Parameters>
<Docs>
<summary>
<para>Constructs and initializes a new instance of the <see cref="T:System.ObjectDisposedException" /> class.</para>
</summary>
<param name="objectName">A <see cref="T:System.String" /> containing the name of the disposed object.</param>
<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="ILASM" Value="public rtspecialname specialname instance void .ctor(string objectName, string message)" />
<MemberSignature Language="C#" Value="public ObjectDisposedException (string objectName, string message);" />
<MemberType>Constructor</MemberType>
<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>
<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>
<param name="message">To be added.</param>
</Docs>
<Excluded>0</Excluded>
</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; };" />
<MemberType>Property</MemberType>
<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; };" />
<MemberType>Property</MemberType>
<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>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="protected ObjectDisposedException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);" />
<MemberType>Constructor</MemberType>
<Parameters>
<Parameter Name="info" Type="System.Runtime.Serialization.SerializationInfo" />
<Parameter Name="context" Type="System.Runtime.Serialization.StreamingContext" />
</Parameters>
<Docs>
<summary>To be added.</summary>
<param name="info">To be added.</param>
<param name="context">To be added.</param>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
<TypeExcluded>0</TypeExcluded>
</Type>
|