Calling a native callback from managed .NET code (when loading the managed code using COM)

Posted by evilfred on Stack Overflow See other posts from Stack Overflow or by evilfred
Published on 2010-05-27T22:23:40Z Indexed on 2010/05/27 22:31 UTC
Read the original article Hit count: 655

Filed under:
|
|
|
|

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!

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET