Compiler Error C3721
Visual Studio .NET 2003
'signature': incompatible signature for event
An event was declared incorrectly. For more information, see __event.
The following sample generates C3721:
// C3721.cpp
// compile with: /clr
#using <mscorlib.dll>
using namespace System;
public __gc class X
{
__event add_E1(); // C3721
__event remove_E1(); // C3721
__event raise_E1();
};
/*
// try the following instead
public __delegate void func(int);
public __gc struct E
{
func* _p;
__event void add_E1(func* p)
{
_p += p;
}
__event void remove_E1(func* p)
{
_p -= p;
}
__event void raise_E1(int i)
{
if (_p != 0)
{
_p->Invoke(i);
}
}
void func2(int i)
{
System::Console::WriteLine(i);
}
};
int main()
{
E* e = new E;
e->E1 += new func(e, &E::func2);
System::Console::WriteLine("hooked");
e->E1(167);
e->E1 -= new func(e, &E::func2);
System::Console::WriteLine("unhooked");
e->E1(167);
}
*/