See Inter-Object Communication, Proxy and Stub.
A client always calls interface
methods in some in-process object. If
the actual object is local or remote,
the call is made to a proxy object,
which then makes a remote procedure
call to the actual object.
So what method is actually executed?
The answer is that whenever there is a
call to an out-of-process interface,
each interface method is implemented
by a proxy object. The proxy object is
always an in-process object that acts
on behalf of the object being called.
This proxy object knows that the
actual object is running in a local or
remote server.
The proxy object packages up the
function parameters in some data
packets and generates an RPC call to
the local or remote object. That
packet is picked up by a stub object
in the server's process on the local
or a remote computer, which unpacks
the parameters and makes the call to
the real implementation of the method.
When that function returns, the stub
packages up any out-parameters and the
return value and sends it back to the
proxy, which unpacks them and returns
them to the original client.
Thus, client and server always talk to
each other as if everything was
in-process.