Search code examples
.netcomactivexipc

ActiveX events with .Net


I've searched on the MSDN but haven't found something conclusive.

I would like to know if it's possible and if yes, how, to expose an event from a C++ ActiveX control and subscribe to it from .Net code. I actually have a polling mechanism, but we would like to replace it with an event-driven mechanism.

If it's not, I plan to use named pipes.


Solution

  • You need to implement COM connection point in a straightforward way (e.g. Visual Studio ATL project wizards are taking care of most of the steps).

    The ActiveX control need to implement connection point, and type library and implemented IProvideClassInfo needs to indicate that coclass is having an outgoing interface. The type library also holds definition of dispinterface for the events.

    When adding a reference to ActiveX control library, .NET interop automatically imports the definitions and adds support for events.

    See: