I am trying to write a managed library in C # that will act as an event source for an existing C ++ event receiver. The problem I am facing is that when an unmanaged application calls AtlAdvise to get a connection point map for my library, the error message "0x80040200" (CONNECT_E_NOCONNECTION) appears. There are several MSDN articles about this error related to unmanaged β uncontrolled communication and an incorrect map of connection points on the COM server, but nothing about the managed COM server.
I downloaded idl from an unmanaged C ++ server that works, and got a list of events that were fired, and then created the same events in my code by doing the following:
Created by a dll that contains the interfaces that I have to implement
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch), Guid("xxxxxx")] public interface IMyInterface { ... methods here ...
Created a dll that has a class that implements 3 required interfaces
[Guid("xxxxxxx2")] [ComSourceInterfaces(typeof(IMyInterface), typeof(IMyOtherInterface), typeof(IMyThirdInterface))] public class DeviceTranslator : IDisposable, IMyInterface, IMyOtherInterface, IMyThirdInterface {
delegates created in the managed interface namespace
namespace myNS.Interfaces { public delegate void DistributeMessage([In] ref OLDMESSAGE Message);
and created events in real IMyInterface
event DistributeMessage myDistributeMessage;
in my class, I implemented an event: public event DistributeMessage myDistributeMessage;
I can place a breakpoint in my constructor, see that the DLL loads properly, but when this part of the unmanaged code gets called, I get the above error: (pDistributeSink is casting CEventSink to IUnknown * and the GUID for IID_IDistributeEvent is the same GUID as IMyInterface)
hr = AtlAdvise(m_pUnknown, pDistributeSink, IID_IDistributeEvent, &m_dwConnectionPointCookie);
At this moment, I am scratching my head completely and donβt understand what else AtlAdvise needs to get the connection point map back from the CLR ...