Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Compiler Error C2717

Error Message

'__nogc new' cannot be used to create a managed type object

__nogc new can only be used to create instances of unmanaged classes and value types. For more information, see __nogc.

C2717 is only reachable using /clr:oldSyntax.

The following sample generates C2717:

// C2717.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>
using namespace System;

__gc class G {};

int main() {
   G* pG = __nogc new G;   // C2717
   G* pG2 = new G;   // OK

   G* arr __gc[] = __nogc new G*[10];   // C2717
   G* arr2 __gc[] = new G*[10];   // OK
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.