Reliability Warnings

Reliability warnings support library and application reliability, such as correct memory and thread usage.

In This Section

Rule

Description

CA2000: Dispose objects before losing scope

Because an exceptional event might occur that will prevent the finalizer of an object from running, the object should be explicitly disposed before all references to it are out of scope.

CA2001: Avoid calling problematic methods

A member calls a potentially dangerous or problematic method.

CA2002: Do not lock on objects with weak identity

An object is said to have a weak identity when it can be directly accessed across application domain boundaries. A thread that tries to acquire a lock on an object that has a weak identity can be blocked by a second thread in a different application domain that has a lock on the same object.

CA2003: Do not treat fibers as threads

A managed thread is being treated as a Win32 thread.

CA2004: Remove calls to GC.KeepAlive

If you are converting to SafeHandle usage, remove all calls to GC.KeepAlive (object). In this case, classes should not have to call GC.KeepAlive, assuming they do not have a finalizer but rely on SafeHandle to finalize the OS handle for them.

CA2006: Use SafeHandle to encapsulate native resources

Use of IntPtr in managed code might indicate a potential security and reliability problem. All uses of IntPtr must be reviewed to determine whether use of a SafeHandle, or similar technology, is required in its place.