How to get object's reference in the server?

321 views Asked by At

When registering an object in the server by

RemotingConfiguration.RegisterWellKnownServiceType(typeof(Interfaces.client), Singleton", WellKnownObjectMode.Singleton); //in the server

then retrieving it in the client by

Interfaces.client mgr = (Interfaces.client)(Activator.GetObject(typeof(Interfaces.client), "tcp://localhost:1234/Singleton")); //in the client

so that the object can be accessed from the client and we can see modifications in the server side, this is already done. My specific problem is: where can I find object's reference in server after it's created? (in singleton or singlecall mode), I know there would be several instances, if it's singlecall mode, even though, I assume that instances are stored by some Naming service macanism, or directly in some list in memory. please forgive my weak English

1

There are 1 answers

2
nblackburn On

You will need to create the object separately then marshal it instead of using RegisterWellKnownServiceType:

Foo foo = new Foo();

RemotingServices.Marshal(foo, "Singleton");

So client changes will be reflected on the server side in the foo object.