Calling a native callback from managed .NET code (when loading the managed code using COM)
- by evilfred
Hi,
I am really confused by the multitude of misinformation about native / managed interop.
I have a C++ exe which is NOT built using CLR stuff (it is not Managed C++ or C++/CLI and never will be). I would like to access some code I have in a C# assembly. I can access the C# assembly using COM. However, when my C# code detects an event I would like it to call back into my C++ code. The C++ function pointer to call back into will be provided at runtime. Note that the C++ function pointer is a function found in the exe's execution environment. I don't want the managed code to try and load up some DLL to call a function (there is no DLL).
How do I pass this C++ function pointer to my C# code through .NET and have my C# code successfully call it?
Thanks!