Re: 0x8001010e The application called an interface that was marshalled for a different thread.
From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 06/04/04
- Next message: Timo Kunze: "Re: MIDL and defaultvalue("\\")"
- Previous message: K.VenkataRamana: "ITaskScheduler"
- In reply to: SLT: "0x8001010e The application called an interface that was marshalled for a different thread."
- Messages sorted by: [ date ] [ thread ]
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?
- Next message: Timo Kunze: "Re: MIDL and defaultvalue("\\")"
- Previous message: K.VenkataRamana: "ITaskScheduler"
- In reply to: SLT: "0x8001010e The application called an interface that was marshalled for a different thread."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|