Connecting a COM Event Source via Interop

0

I am trying to expose a COM Event Source from C#. I have the following event interface that is imported from a TLB:

[Guid("AAAABBBB-CCCC-DDDD-EEEEFFFFAAAA")]
[InterfaceType(2)]
[TypeLibType(4096)]
public interface _IFooEvents
{
   [DispId(20)]
   void FooEvent(int Value);
   // Remainder of elements omitted for brevity
}

I'm attempting to implement this event interface as a source on a ComVisible object defined in my application:

[ComVisible(true), Guid("FFFFEEEE-DDDD-CCCC-BBBBAAAAFFFF")]
[ComSourceInterfaces("_IFooEvents")]
class FooConcrete : IFoo
{
    [ComVisible(false)]
    public delegate void FooEvent(int Value);
    // Remainder of delegates omitted for brevity.

    public event FooEvent TheFooEvent;

 }

This source is then used by a sink implemented in C++ using ATL.

HRESULT AdviseResult = _IDispEvent::DispEventAdvise(pUnk, IID__IFooEvents);

The HRESULT returned is 0x80131522: Could not find or load a type.

c#
com-interop
asked on Stack Overflow Jun 28, 2017 by lcs

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0