This documentation is archived and is not being maintained.

Compiler Error C2346

Error Message

'function' cannot be compiled as native: reason

The compiler was unable to compile a function MSIL.

For more information, see managed, unmanagedand /clr (Common Language Runtime Compilation).

To correct this error

  1. Remove the code in the function that cannot be compiled to MSIL.

  2. Do not compile the module with /clr or mark the function as unmanaged with the unmanaged pragma.


The following sample generates C2346.

// C2346.cpp
// compile with: /clr /c
// C2346 error expected
// processor: x86
#include <dos.h>   // definitions for _disable, _enable
#pragma intrinsic(_disable)
#pragma intrinsic(_enable)

ref class C {
   Object ^ f0;
   Object ^ f1() { 
      return f0;

   void f2() {

   static void f3() {