Re: 0x8001010e The application called an interface that was marshalled for a different thread.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 06/04/04


Date: Thu, 3 Jun 2004 22:34:04 -0700

You don't need to do any of this at the client. All the work is
at the server. What is its threading model? I presume single,
this is the ATL default (your mentioning Both makes no sense,
since these are only meaningful for in-proc servers, check the
call to CoInitialize[Ex]). And I suppose you have a worker
thread that creates another STA. Then you'd need some of
that stuff in entry 1 in the MVP COM/ATL FAQ in my
signature.

-- 
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"SLT" <small-lemon-tree@yahoo.com> wrote in message
news:38d9bbd1.0406031208.1cc29059@posting.google.com...
> Hello.
>
> I have an MFC executable that wants to receive events from a COM
> object created in another executable.  This MFC executable has a
> pointer to this object and things are good.  The MFC executable
> creates a CCmdTarget-based sink object, gets the IDispatch* to it,
> creates a stream, CoMarshalInterface()'s this pointer to the stream,
> gets the IUnknown* to the stream and passes it to
> AfxConnectionAdvise().
>
> I overrode the IConnectionPointImpl<>::Advise() on the other side to
> get the IStream* to what was passed in, seeks back to zero,
> CoUnmarshalInterface()'s it, and stores the nice unmarshalled
> interface in the same manner that it would have if I didn't override
> Advise().
>
> All of these calls work fine and everyone is happy.
>
> Until an event fires.
>
> The pConnection->Invoke() call *STILL* fails with "The application
> called an interface that was marshalled for a different thread.".
>
> The MFC executable enters an STA.  The COM object is marked as 'Both'.
>  The MFC executable and the COM object are in two separate processes.
> I would have thought that the above method would have worked.  I feel
> like cheating and posting window messages instead of using the
> connection point but I really want to get it to work.  I have read all
> of the FAQs and posts that I could find but most deal with passing
> events within the same process, using CWindowImpl<> or the GIT, both
> of which I have been able to do successfully in the past.
>
> Any ideas?


Relevant Pages

  • Re: Why the .pdf can not be shown?
    ... Juan T. Llibre, asp.net MVP ... asp.net faq: http://asp.net.do/faq/ ... However, after deploying it to the server and running it on server IE, to my ... Internet Explorer was unable to link to the Web page you requested. ...
    (microsoft.public.dotnet.framework.aspnet)
  • VC++ FAQ moved
    ... With the help of Karl Petterson, we've moved tonight the old MVP VC++ FAQ ... over to the new MVPS.ORG server. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: SQL SERVER 2000 or MDE
    ... Juan T. Llibre, asp.net MVP ... asp.net faq: http://asp.net.do/faq/ ... SERVER 2000. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Accessing Email
    ... >>You can disable the protocol at various levels, the user, ... >the server ... Mark Arnold MCSA MCSE+M MVP, ... FAQ: http://www.swinc.com/resource/exchange.htm & ...
    (microsoft.public.exchange.admin)
  • alt.2600 FAQ Revision .014 (1/4)
    ... The "Survival Guide" is a supplement to this FAQ and should be considered to be part of it. ... How do I attack a remote network across the Internet? ... This involves translations in which several different values are represented by the same character, which is why Unix passwords cannot be decrypted. ... The audit server database is called SYS$COMMON:VMS$AUDIT_SERVER.DAT and the audit log file is SYS$COMMON:SECURITY.AUDIT$JOURNAL. ...
    (alt.2600)