We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.
CA2220: Finalizers should call base class finalizer
Visual Studio 2010
TypeName | FinalizersShouldCallBaseClassFinalizer |
CheckId | CA2220 |
Category | Microsoft.Usage |
Breaking Change | Non Breaking |
A type that overrides Object.Finalize does not call the Finalize method in its base class.
Do not suppress a warning from this rule. Some compilers that target the common language runtime insert a call to the base type's finalizer into the Microsoft intermediate language (MSIL). If a warning from this rule is reported, your compiler does not insert the call, and you must add it to your code.
The following Visual Basic example shows a type TypeB that correctly calls the Finalize method in its base class.
Imports System Namespace UsageLibrary Public Class TypeB Inherits TypeA Protected Overrides Sub Finalize() Try Dispose(False) Finally MyBase.Finalize() End Try End Sub End Class End Namespace
Show: