Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello again,

I have some problems with my implementation of IConnectionPointContainer and IConnectionPoint. Actually the IConnectionPointContainer works like it should but the IConnectionPoints seems to not get the input it likes when my .NET-application adds an event to the point.

The problem occurs in my implementation of IConnectionPoint::Advise. According to the MSDN the IUnknown supplied as an argument should support the interface represented by this connection point. But calling QueryInterface on that IUnknown always gives me E_NOINTERFACE. I displayed the IID requested in the IConnectionPointContainer (in FindConnectionPoint) and compared it to the IID i pass to QueryInterface in IConnectionPoint::Advise and they are the same.

Here with some code:
IConnectionPointContainer::FindConnectionPoint:
C++
STDMETHOD(FindConnectionPoint)(REFIID iid, IConnectionPoint** ppConnPtr)
{
    if(ppConnPtr == NULL)
        return E_POINTER;

    if(mConnectionPoints.find(iid) == mConnectionPoints.end())
        return CONNECT_E_NOCONNECTION;

    *ppConnPtr = mConnectionPoints[iid];
    mConnectionPoints[iid]->AddRef();
    return S_OK;
}


Outputs show me that the connection point is successfully found.

IConnectionPoint::Adivse (just the start)
C++
STDMETHOD(Advise)(IUnknown* pUnkSink, DWORD* pdwToken)
{
    std::cout << __FUNCTION__ << std::endl;
    if(!pdwToken)
    {
        std::cout << "return E_POINTER;" << std::endl;
        return E_POINTER;
    }

    *pdwToken = 0;
    T* connObj = NULL;
    if(FAILED(pUnkSink->QueryInterface(&connObj))) // <--- E_NOINTERFACE
    {
        std::cout << "return CONNECT_E_CANNOTCONNECT;" << std::endl;
        return CONNECT_E_CANNOTCONNECT;
    }

    ...
}


Anyone got a clue why this is happening or if i understood something wrong in the MSDN?

Thanks a lot,
Regner
Posted
Comments
Regner44 11-Jun-11 5:40am    
I think i already got it, the Sink implements IDispatch and not necessarily my event-Interface.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900