|
55 | 55 | <format type="text/markdown"><![CDATA[
|
56 | 56 |
|
57 | 57 | ## Remarks
|
58 |
| - An <xref:System.ObjectDisposedException> is thrown when you try to access a member of an object that implements the <xref:System.IDisposable> interface, and that object has been disposed. Typically, this exception is caused by one of the following conditions: |
| 58 | + An <xref:System.ObjectDisposedException> is thrown when you try to access a member of an object that implements the <xref:System.IDisposable> interface or <xref:System.IAsyncDisposable> interface, and that object has been disposed. Typically, this exception is caused by one of the following conditions: |
59 | 59 |
|
60 |
| -- You've called an object's `Dispose` method, and you're trying to access an instance member that gets or sets the object's state. The following example illustrates the <xref:System.ObjectDisposedException> that is thrown when you try to reset the frequency of timer notifications after you call the <xref:System.Threading.Timer.Dispose%2A?displayProperty=nameWithType> method. |
| 60 | +- You've called an `IDisposable` object's `Dispose` method (or an `IDisposableAsync` object's `DisposeAsync` method), and you're trying to access an instance member that gets or sets the object's state. The following example illustrates the <xref:System.ObjectDisposedException> that is thrown when you try to reset the frequency of timer notifications after you call the <xref:System.Threading.Timer.Dispose%2A?displayProperty=nameWithType> method. |
61 | 61 |
|
62 | 62 | :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.objectdisposedexception/cs/dispose1.cs" id="Snippet1":::
|
63 | 63 | :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.objectdisposedexception/vb/dispose1.vb" id="Snippet1":::
|
64 | 64 |
|
65 |
| -- You've called an object's `Close` method, and you're trying to access an instance member that gets or sets the object's state. Often, the `Close` method provides a type's public implementation of the <xref:System.IDisposable.Dispose%2A?displayProperty=nameWithType> method. |
66 |
| - |
67 |
| -- You've called an object's `Dispose` method multiple times. Typically, this doesn't throw an exception. However, depending on how a type implements <xref:System.IDisposable.Dispose%2A?displayProperty=nameWithType>, it may not allow multiple calls to `Dispose`. |
| 65 | +- You've called an object's `Close` method, and you're trying to access an instance member that gets or sets the object's state. Often, the `Close` method provides a type's public implementation of the <xref:System.IDisposable.Dispose%2A?displayProperty=nameWithType> method. The same is true for `CloseAsync` and `<xref:System.IAsyncDisposable.DisposeAsync%2A?displayProperty=nameWithType>`. |
68 | 66 |
|
| 67 | +- You've called an object's `Dispose` or `DisposeAsync` methods multiple times. Typically, this doesn't throw an exception. However, depending on how a type implements <xref:System.IDisposable.Dispose%2A?displayProperty=nameWithType> or <xref:System.IAsyncDisposable.DisposeAsync%2A?displayProperty=nameWithType>, it may not allow multiple calls to that method. |
| 68 | +
|
69 | 69 | In most cases, this exception results from developer error. Instead of handling the error in a `try`/`catch` block, you should correct the error, typically by reinstantiating the object.
|
70 | 70 |
|
71 | 71 |
|
|
0 commit comments