NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Compiler Error C3731

incompatible event 'function1' and handler 'function2'; event source and event handler must be the same type

The event source and event receiver must have the same type (for example native vs. com types). To fix this error, make the types of the event source and the event handler match.

The following sample generates C3731:

#using <mscorlib.dll>
[event_source(native)]
struct A {
        __event void MyEvent();
};

[event_receiver(com+)]
// try the following line instead
// [event_receiver(native)]
struct B {
        void func();
        B(A a) {
                __hook(&A::MyEvent, &a, &B::func);   // C3731
        }
};

void main() {
}