How to pass C# method as a callback to CLI/C++ function?
问题 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++? 回答1: If neither of you is