Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 3.0
Tools
Development Tools
FxCop
FxCop Warnings
Usage Warnings
 Do not dispose objects multiple tim...
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Studio Team System
Do not dispose objects multiple times

TypeName

DoNotDisposeObjectsMultipleTimes

CheckId

CA2202

Category

Microsoft.Usage

Breaking Change

NonBreaking

A method implementation contains code paths that could cause multiple calls to System.IDisposable.Dispose or a Dispose equivalent (such as a Close() method on some types) on the same object.

A correctly implemented Dispose method can be called multiple times without throwing an exception. However, this is not guaranteed and to avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.

To fix a violation of this rule, change the implementation so that regardless of the code path, Dispose is called only one time for the object.

Do not exclude a warning from this rule. Even if Dispose for the object is known to be safely callable multiple times, the implementation might change in the future.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker