我正在尝试从C#公开COM事件源。 我有从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
}
我试图将此事件接口实现为我的应用程序中定义的ComVisible
对象的源:
[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;
}
然后,使用ATL在C ++中实现的接收器使用此源。
HRESULT AdviseResult = _IDispEvent::DispEventAdvise(pUnk, IID__IFooEvents);
返回的HRESULT
为0x80131522: Could not find or load a type
。