编译器错误 C3386

“type-name”:__declspec(dllexport)/__declspec(dllimport) 不能应用于托管类型或 WinRT 类型

dllimportdllexport__declspec 修饰符在托管类型或 Windows 运行时类型上无效。

下面的示例生成 C3386,并演示如何修复此错误:

// C3386.cpp
// compile with: /clr /c
ref class __declspec(dllimport) X1 {   // C3386
// try the following line instead
// ref class X1 {
};