We help IT Professionals succeed at work.

Question about Sink (COM)

MichaelMaromm
on
Hi,

I've created a sink class , but the advise function returns the error code 0x80040202 CONNECT_E_CANNOTCONNECT.
Other sinks work OK.
I've checked , also, the COM map, and it is OK too.

My question is :
What other checks should I make ?

Michael
/////////////////////////////////////////////////////////

The PROBLEMATIC sink :

class CProblematicSink  :
                  public CComObjectRoot,
            public _IProblematicEvents
{
// Constructor / Destructor
public:
   CProblematicSink() {}
    virtual ~CProblematicSink() {}

// Interfaces details
     BEGIN_COM_MAP(CSecondSink)
       COM_INTERFACE_ENTRY(IDispatch)
       COM_INTERFACE_ENTRY(_IProblematicEvents)
    END_COM_MAP()

// IDispatch Implementation
public :
    STDMETHODIMP GetTypeInfoCount(UINT*);
    STDMETHODIMP GetTypeInfo(UINT iTInfo,LCID
                  lcid,ITypeInfo **ppTInfo);
    STDMETHODIMP GetIDsOfNames(REFIID riid,
                               LPOLESTR *rgszNames,
                               UINT cNames,
                               LCID lcid,
                               DISPID *rgDispId);

    STDMETHODIMP Invoke( DISPID dispIdMember,
                         REFIID riid, LCID lcid,
                         WORD wFlags,
                         DISPPARAMS *pDispParams,
                         VARIANT *pVarResult,
                         EXCEPINFO *pExcepInfo,
                         UINT *puArgErr);

// Interface callback events
public:
    void OnEvent(OLECHAR *wCode);
   

};



////////////////////////////////////////////////////////

The following sink class that works with advise is :

class CGoodSink  :
                  public CComObjectRoot,
            public _IGoodEvents
{
// Constructor / Destructor
public:
    CGoodSink() {}
    virtual ~CGoodSink() {}

// Interfaces details
    BEGIN_COM_MAP(CGoodSink)
       COM_INTERFACE_ENTRY(IDispatch)
       COM_INTERFACE_ENTRY(_CGoodSink)
    END_COM_MAP()

// IDispatch Implementation
public :
STDMETHODIMP GetTypeInfoCount(UINT*);
STDMETHODIMP GetTypeInfo(UINT iTInfo,LCID lcid,
              ITypeInfo **ppTInfo);
STDMETHODIMP GetIDsOfNames(REFIID riid,
                           LPOLESTR  *rgszNames
                           ,UINT cNames,LCID lcid,
                           DISPID *rgDispId);
STDMETHODIMP Invoke( DISPID dispIdMember, REFIID riid,
                     LCID lcid,WORD wFlags,
                     DISPPARAMS *pDispParams,
                     VARIANT *pVarResult,
                     EXCEPINFO *pExcepInfo,
                     UINT *puArgErr);

// Interface callback events
public:
    void OnEvent(OLECHAR *wCode);
};
///////////////////////////////////////////////////////


Comment
Watch Question

ekc

Commented:
Are you sure that GUID of the problematic sink interface is the same as the GUID of the _IProblematicEvents?
It has to be.
Besides, if this interface is implemented by some object wanting to receive events, you'll have to add it manualy to IDL of this object. At least, I haven't find the way of doing this differently...
I use IDispEventImpl when dealing with sink only objects

class CEventHandler :
     public IDispEventImpl<0,CEventHandler,&DIID__DEvents,&LIBID_MYLIB, 1, 0>
{
public:
     CEventHandler()
     {
     }

BEGIN_SINK_MAP(CEventHandler)
     SINK_ENTRY_EX(0, DIID__DEvents, 0x0, Method1)
     SINK_ENTRY_EX(0, DIID__DEvents, 0x1, Method2)
END_SINK_MAP()


// DIID__DEvents
public:
     STDMETHOD_(void,Method1)(/*[in]*/IDispatch* Queue, /*[in]*/long lData);
     STDMETHOD_(void,Method2)(/*[in]*/IDispatch* Queue, /*[in]*/long lErrorCode, /*[in]*/long lData);


};

do you have/require a proxy/stub dll  to do the work or are you using typelibrary marshalling

Commented:
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and PAQ at zero points since
you already received an answer in http://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=20273781

You have 10 open questions out of 26 that need your attention. If you re=ceived an answer, please accept it, so that it will be closed. If experts asked for feedback, please provide help if possible.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner

Admin notified of User neglect. Force-accepted by
Netminder
CS Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.