javatopia
10/19/2004 5:13:00 PM
Hello,
I have a windows service that sets up the remoting server context for a
remoted class (a facade for a series of singleton classes). The
client-server part seems to work, but when I try to access the remoted data
from the windows service, it is not there. It is as if the singleton has
been re-instantiated, which makes me think the remote context runs in its own
AppDomain.
When a class is setup to be remoted, does it run in its own AppDomain,
exclusive of the primary AppDomain setting up the remoting context? If so,
do I have to use the remote client API to get at the actual data from the
windows service?
I am running framework version 1.1 SP1. My intentions are to make the
remoted data persist in a file when the windows service is stopped, and then
be reloaded when it starts again.
Maybe I should be using some other aspect of the framework to do the
persistence?? (I should be using COM+, but I like windows services)
<CODE>
class MySingletonClass : MarshalByRefObject {
private static MySingletonClass _Instance = new MySingletonClass();
public static MySingletonClass Instance { get { return(_Instance); } }
public void SaveState() { ... }
public void LoadState() { ... }
}
class MyRemoteFacade : MarshalByRefObject {
public MySingletonClass SingletonInstance {
return(MySingletonClass.Instance);
}
}
The windows service class has these two methods of interest:
public void OnStart() {
(new MyRemoteFacade()).SingletonInstance.Load(filename);
}
public void OnStop() {
(new MyRemoteFacace()).SingletonInstance.Save(filename);
}
I also tried it without using the remote facade:
public void OnStart() {
MySingletonClass.Instance.Load(filename);
}
public void OnStop() {
MySingletonClass.Instance.Save(filename);
}
Neither of which worked - the save file never contains the runtime state,
only the initial state of the singleton.
Thanks
-- Jake
jwa@javatopia.com