I did this to call an unmanaged function from C. pCallback is a pointer to a function, so the managed party is a delegate.
[DllImport("MyDLL.dll")]
public static extern Result SetCallback(
IntPtr handle,
Delegate pCallback,
CallbackType Type);
Now i install
private delegate void pfnCallback(uint PromptID, ttsEventType evt, IntPtr lData);
private pfnCallback cb = new pfnCallback(cback);
public Form1()
{
(...)
Wrapper.SetCallback(handle, cb, IntPtr.Zero, CallBackType.DEFAULT);
(...)
public static void cback(uint PromptID, ttsEventType evt, IntPtr lData)
{ }
}
When debugging, I see that it runs the cback function once, and then I get an exception with no data, just saying: "An unhandled win32 exception occurred in WindowsApp2.vshost.exe [4372]. I donβt understand what is False. Can anyone will you help me?
source
share