Do SingleCall server activation objects retain state across calls?

S

Sathyaish

Do SingleCall server activation mode objects retain their state across
different calls?

For e.g.

Server code:
------------
//RemoteServerObject's activation mode is server activation. The
WellKnownObjectMode enum value assigned is SingleCall, done in config
file.

public class RemoteServerObject: MarshalByRef
{
private int _value = 0;

public void SetValue(int value)
{
this._value = value;
}


public int GetValue()
{
return this._value;
}
}


Client code:
-------------

RemoteServerObject r = new RemoteServerObject(); //Nothing happens
here

r.SetValue(3); //New instance of RemoteServerObject created on server.
It's _value set to 3.

/* Suppose that the lifetime lease of r expires here */

Console.WriteLine( r.GetValue().ToString() ); //Another instance
created by server. Question: Will this instance retain the value 3?


My common sense says that the remoting infrastructure would persist
state of the object across its various lifetimes. but I don't know for
sure.
 
A

Andy

I'm not 100% sure, but I don't think any state is retained
automatically. If you need this, you'd have to do it yourself, but
it's not trivial.
 
N

Nicholas Paldino [.NET/C# MVP]

It doesn't matter. The object is released after the call. This is what
makes it SingleCall. You get a new instance every time you make a new call.
 

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