Creating a remotable object like DCOM

J

Jayme Pechan

Does anyone know if it is possible to return an object from a remoting
interface and have it be usable with .NET? I am trying to accomplish what I
used to do in DCOM where I would call a function on an interface and it
would return a new remote object. I could then call functions on that new
object. When I attempt this with .NET it complains that the object has no
channel sink. When I looked into the .NET configuration settings, this
scenerio didn't seem to fit the 3, SingleCall, SingleInstance, or Client
Initiated. The closest one I could think of was Client Initiated but it is
the server that creates the object. Any ideas? Is this just not possible
with .NET?

Thanks.

Jayme
 
D

Dmytro Lapshyn [MVP]

Jayme,

In DCOM, AFAIR it is also the server who creates the object - an interface
you are given is actually only a proxy (or stub, can't remember exactly
which of them runs on the client side).
 
J

Jayme Pechan

Right, in DCOM, I create the object on the server and it marshals the
interface to the client which is a proxy because all calls to the object get
marshalled to the server. The point though is that the client maintains a
reference to a unique object on the server with its own state and such until
it is released by the client. I need to find some way to do this same
thing, if possible, in .NET. It looks like it is impossible.

Thanks.

Jayme
 
D

Dmytro Lapshyn [MVP]

I've checked with MSDN docs and the Client Activation mode is just what you
need. To quote the "Client Activation" topic from MSDN's .NET Framework
Developer's Guide:

"Client-activated objects are objects whose lifetimes are controlled by the
calling application domain, just as they would be if the object were local
to the client. With client activation, a round trip to the server occurs
when the client tries to create an instance of the server object, and the
client proxy is created using an object reference (ObjRef) obtained on
return from the creation of the remote object on the server. Each time a
client creates an instance of a client-activated type, that instance will
service only that particular reference in that particular client until its
lease expires and its memory is recycled. If a calling application domain
creates two new instances of the remote type, each of the client references
will invoke only the particular instance in the server application domain
from which the reference was returned.
In COM, clients hold an object in memory by holding a reference to it. When
the last client releases its last reference, the object can delete itself.
Client activation provides the same client control over the server object's
lifetime, but without the complexity of maintaining references or the
constant pinging to confirm the continued existence of the server or client.
Instead, client-activated objects use lifetime leases to determine how long
they should continue to exist."

Please refer to the whole topic for more information:

http://msdn.microsoft.com/library/d.../en-us/cpguide/html/cpconclientactivation.asp
 
J

Jayme Pechan

That seems sensible but they require that the object be created from the
client (apparently). If its possible to do what I want, this would have to
be the right one. Thanks for the suggestion.

Jayme
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top