Export (0) Print
Expand All
Expand Minimize

Compiler Error C3742

Visual Studio .NET 2003

'type': could not convert to System::Type*

An attempt was made to use typeof on an unmanaged type.

The following sample generates C3742:

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

__nogc struct MyStruct {
};

// try the following lines instead
// __gc struct MyStruct {
// };

[attribute(All)]
__gc struct AtClass {
   AtClass(System::Type*) {
   }

   AtClass(String*) {
   }

   AtClass(int) {
   }
};

[AtClass(typeof(MyStruct))]
struct B {   // C3742
};

int main() {
}
Show:
© 2015 Microsoft