Export (0) Print
Expand All
Expand Minimize

Compiler Error C3175

Error Message

'function1' : cannot call a method of a managed type from unmanaged function 'function2'

Unmanaged functions cannot call member functions of managed classes.

The following sample generates C3175:

// C3175_2.cpp
// compile with: /clr

ref struct A {
   static void func() {
   }
};

#pragma unmanaged   // remove this line to resolve

void func2() {
   A::func();   // C3175
}

#pragma managed

int main() {
   A ^a = gcnew A;
   func2();
}

The following sample generates C3175:

// C3175.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>

__gc struct A
{
   static void func()
   {
   }
};

#pragma unmanaged   // remove this line to resolve

void func2()
{
   A::func();   // C3175
}

#pragma managed

int main()
{
   A *a = new A;
   func2();
}

Community Additions

ADD
Show:
© 2015 Microsoft