Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C3840

Error Message

declaration of 'method' not allowed; use destructors to implement finalization

Declare a destructor instead of a Finalize method in a managed class.

C3840 is only reachable using /clr:oldSyntax.

The following sample generates C3840:

// C3840.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>
__gc class X
{
protected:

   void Finalize()
   {   // C3840, "declaration of 'X::Finalize' not allowed...
   }

   // declare a destructor instead
   // ~X()
   // {
   // }
};

int main()
{
}

Community Additions

ADD
Show:
© 2015 Microsoft