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 C2814

Error Message

'member' : a native type cannot be nested within a managed type 'type'

Example

A native type cannot be nested in a CLR type. The following sample generates C2814.

// C2814.cpp
// compile with: /clr /c
ref class A {
   class B {};   // C2814
   ref class C {};   // OK
};

You must explicitly specify the "managed-ness" of an embedded type using one of the following keywords: __gc, __nogc, or __value.

The following sample generates C2814.

// C2814_b.cpp
// compile with: /clr:oldSyntax /c
__gc class A {
   class B {};   // C2814
   __gc class C {};   // OK
};

Community Additions

ADD
Show:
© 2015 Microsoft