Hello,

It sounds like you're passing the client interface reference to the 
server in the context of a client thread, and are then trying to use 
that reference directly from the context of another thread (maybe the 
main application thread) in the server, to call back to the client.  
IIRC, you can't do that in apartment model threading, and you have to 
first marshal the reference into the new thread context, (via a stream), 
something like so (untested):

var  FStream: Pointer;

  // in thread receiving server reference
  OleCheck(CoMarshalInterThreadInterfaceInStream(  IServer, IServerImpl, 
IStream(FStream)));
 ...
  // in thread wanting to call the server reference
 OleCheck(CoGetInterfaceAndReleaseStream( IStream(FStream), IServer, 
IServerImpl));

Also have a read of:
http://msdn2.microsoft.com/en-us/library/ms693316.aspx
and
http://msdn2.microsoft.com/en-us/library/ms691421.aspx

Hope that helps (haven't worked with this for some time so ... :-/  )

Walter Prins


reynaldi81 wrote:
>
> hi all,
>
> i currently developing a client server application. i have IServer
> interface which will be used by the client to communicate with the
> server and ICLient for the server to talk back to the client, both in
> the same type library which is shared between client and server
> application. the client have no problem communicating with the server.
> but when the server try to call methods in client through IClient
> interface, i get this strange error "The application called an
> interface that was marshalled for a different thread". can anyone help
> me on this problem. i use the Apartment Model.
>
>   


[Non-text portions of this message have been removed]

Reply via email to