I try to avoid using Type Libraries for COM automation with C#, but instead using the dynamic keyword to resolve types at runtime. This works fine, except when trying to define event handler.
I've tried to define it this way:
_COMObject.OnStop += new Action(OnStop);
The original COM object however defines its ownEventHandler type with no arguments and no return value. Thus of course Action is not the same type then and this results in a RuntimeBinderException stating that it can not convert the Action type to the ComObjectCustomEventHandler although they have the same signature.
I would need to have something like a dynamic delegate, however I haven't figured out how to define it.
HRESULT OnStop();