Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

COM error creating BHO and APP

14 views
Skip to first unread message

spidy

unread,
Aug 15, 2009, 3:41:31 PM8/15/09
to
I created a BHO and implemented a protocol handler .
Now in BHO setSite method I am creating Protocol class factory and
then calling registernamespace in IInternetSession.

CComPtr<IClassFactory> m_spCF;
CComPtr<IInternetSession> spSession;
hr = CoInternetGetSession(0, &spSession, 0);
if (SUCCEEDED(hr))
{
m_spCF.CoCreateInstance(CLSID_ProtocolHandlerCF);
if(SUCCEEDED(hr))
{
hr = spSession->RegisterNameSpace(m_spCF, CLSID_NULL, L"http", 0,
0, 0);
}
}

This works fine but when I run it gives me error and IE exists.

Error is
---------------------------
Windows Internet Explorer
---------------------------
Internet Explorer cannot download fwlink/ from go.microsoft.com.

The application called an interface that was marshalled for a
different thread.


---------------------------
OK
---------------------------


AS per my understanding , BHO is launched by IE and APP is created by
BHO.

Both BHO and APP are in same dll. Is there any issue with this? Am I
doing something wrong..

Igor Tandetnik

unread,
Aug 15, 2009, 11:31:52 PM8/15/09
to
spidy wrote:
> I created a BHO and implemented a protocol handler .
> Now in BHO setSite method I am creating Protocol class factory and
> then calling registernamespace in IInternetSession.
>
> CComPtr<IClassFactory> m_spCF;
> CComPtr<IInternetSession> spSession;
> hr = CoInternetGetSession(0, &spSession, 0);
> if (SUCCEEDED(hr))
> {
> m_spCF.CoCreateInstance(CLSID_ProtocolHandlerCF);
> if(SUCCEEDED(hr))
> {
> hr = spSession->RegisterNameSpace(m_spCF, CLSID_NULL, L"http", 0,
> 0, 0);
> }
> }
>
> This works fine but when I run it gives me error and IE exists.
>
> The application called an interface that was marshalled for a
> different thread.

URLMon doesn't follow COM rules and freely passes interface pointers
between threads. This only works as long as they are all direct
pointers. Somehow, you've gotten a proxy pointer in there, and the proxy
complains about being called from the wrong thread.

Say, what threading model is CLSID_ProtocolHandlerCF coclass registered
with? Not free-threaded, by any chance?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


0 new messages