WinRT 或托管事件的声明必须出现在 WinRT 或托管类型中
Windows 运行时事件或托管事件是在本机类型中声明的。 要修复此错误,请在 Windows 运行时类型或托管类型中声明事件。
有关详细信息,请参阅事件。
下面的示例生成 C3909,并演示如何修复此错误:
// C3909.cpp
// compile with: /clr /c
delegate void H();
class X {
event H^ E; // C3909 - use ref class X instead
};
ref class Y {
static event H^ E {
void add(H^) {}
void remove( H^ h ) {}
void raise( ) {}
}
};