0

This is similar to:

Calling C# code from unmanaged C++?

but the opposite. I have some managed C#/C++CLI code that has triggering events. (I don't have access to the code, just the dll). I'd like to add my own C++ functions to be triggered on the events, but can't seem to get the typing right for them to be acceptable.

The dll specification for the type is a "public void delegate" which is not even valid (unmanaged) C++ syntax. Yet the COM interface functions.

The type I need to be compatible with is (from the .tlh file):

struct __declspec(uuid("72181a6f-4cc6-39aa-89d2-c8c4fd0cab3f"))
_RecordUpdatedDelegate : IDispatch
{};

All the other solutions for 'baking' a function pointer into a C# delegate involve having some access to the C# side. I don't have that luxury. I'm thinking this is either something someone has done many times or it is impossible.

Community
  • 1
  • 1
Jiminion
  • 5,080
  • 1
  • 31
  • 54
  • 1
    So you have a COM event source written in C#, and need to know how to write a COM event sink in unmanaged C++? If so, you will want to research "event sink" and "connection point" in relation to COM. – Ben Voigt Jun 04 '14 at 20:46
  • Update: No real answer so far. I can cheat by having a C++/CLI program, which I might end up doing, but it's not so pretty. – Jiminion Jun 10 '14 at 20:13
  • "All the other solutions for 'baking' a function pointer into a C# delegate..." Could you post a link to those solutions? – Sergio Basurco Mar 04 '15 at 08:15
  • I haven't worked on that problem in quite some time. But I remember it wasn't that bad. You just needed to get the delegate to trigger some kind of (standard) C++ Observer. It wasn't very hard, but there was a two step aspect to it. I'll try to find a code fragment if I can, – Jiminion Mar 04 '15 at 14:13

0 Answers0