[Mono-list] Garbage-collecting a remoting singleton object in a service?
robertj at gmx.net
Fri Sep 1 10:05:36 EDT 2006
Andrés G. Aragoneses [ knocte ] wrote:
> I am interested in implementing a service (windows service in windows,
> and using mono-service on linux, I suppose) that hosts a singleton
> remoting object. As I have read on some docs, no leasing management is
> needed if no SAO/CAO hosting method is used (returning null in
> InitializeLifeTimeService method, as I will use a Singleton instance)
> but, how can I garbage-collect manually this server object on the
> OnStop() method of the service (so as to create a new instance again on
> the OnStart method)?
To achieve this, you have to register the singleton object manually.
Throw away the <service> entry from you server's remoting config
and use this code instead (in server's code, of course):
singleton = new YourServerClass ();
RemotingServices.Marshal (singleton, objectUri);
// do what you called "garbage-collect manually".
where "objectUri" is the objectUri-attribute you previously
used in server's remoting config.
More information about the Mono-list