I have such method in C++/CLI:
void Foo(OnEngineCloseCallback callback);
with such callback definition:
typedef void (*OnEngineCloseCallback)( int, String ^ errorMessage);
The C++/CLI compiles. The C# code looks like this:
static void onCallback( int code, String errorMessage)
{
System.Diagnostics.Debug.WriteLine(errorMessage);
}
and the call:
Foo(onCallback); // error
"Foo is not supported by the language" (error: CS0570).
So how can I pass my callback to CLI/C++?
If neither of you is going to post an answer I'll do it because I don't like answered questions without answers...
You must declare a public delegate, not a function pointer. Basic how-to article is here. by Hans Passant
How to: Define and Use Delegates (C++/CLI)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With