This message was discovered on microsoft.public.dotnet.framework.remoting.
| Chris Soulsby |
I have application which hides itself after it is closed and places a icon in task tray. When you run the program it will check to see if its running and if it is then contact the application using remoting and tell it to show its self.
This seems to work fine, however, after a while it seems to loose the remoting server. The client application gets a RemotingException "Requested Service not found". The server application is still running in the task tray.
Does anyone know why it would work for a while then stop?
The following code is used on the server:
// create a server System.Runtime.Remoting.RemotingServices.Marshal(this, NAME); Hashtable ht = new Hashtable(); ht["bindTo"] = "127.0.0.1"; ht["port"] = "0"; m_oTcpChannel = new System.Runtime.Remoting.Channels.Tcp.TcpChannel(ht, null, null); System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(m_oTcpChann el);
// write url to isolated storage IsolatedStorageFile isoFile; isoFile = IsolatedStorageFile.GetUserStoreForDomain(); IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(FILENAME, FileMode.OpenOrCreate, FileAccess.Write, isoFile); StreamWriter writer = new StreamWriter(isoStream); writer.WriteLine(m_oTcpChannel.GetUrlsForUri(NAME)[0]); writer.Close(); isoFile.Dispose(); isoFile.Close(); .... Application.Run();
And the following code is used on the client:
// read the url from the file IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain , null, null); IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(FILENAME, FileMode.Open, FileAccess.Read, FileShare.Read); StreamReader reader = new StreamReader(isoStream); string strMutex = reader.ReadLine(); reader.Close(); isoFile.Close();
try { // create a remote instance of this class SingleInstanceClass o = (SingleInstanceClass)System.Runtime.Remoting.RemotingServices.Connect(typeof (SingleInstanceClass), strMutex); o.MultipleInstances(); }
|
|
|
| |
|
| |
| |
| Allen Anderson |
how are you handling your lifetime services? Are you making a new object/connection each time you wake up or are you trying to re-use the same connection? Remoting services will time your object out after a few minutes unless you implement either a null lifetime (forever) or sponsors/leases to control exactly how long the object will live. The easiest to do this in your particular low use case would probably just be to create a new remote object each time you want to change the state of your application.
Allen Anderson http://www.glacialcomponents.com mailto: allen@put my website url here.com
On Thu, 8 Apr 2004 15:33:49 +0100, "Chris Soulsby" <chris.soulsby(at)sysinx.com> wrote:
[Original message clipped]
|
|
|
| |
|
| |
|
| |
| Edward J. Stembler |
The connection dies after 5 mins. You have to override InitializeLifetimeService or create a lease.
Here's an example of overriding ILS:
public override object InitializeLifetimeService() { return null; // return null to live forever }
"Chris Soulsby" <chris.soulsby(at)sysinx.com> wrote in message news:<Click here to reveal e-mail address>... [Original message clipped]
|
|
|
| |
|
|
| |
| |
| Ice |
So lets say I'm using a SingleCall object, as far as the object finishes it work in under 5 minutes I'm golden. With Singletons, its almost common sense that the object live forever and so I would have to override the lifetime. However, with CAOs, leases and lifetime would definitely have to thought out a little more as the client should be in charge of how long the object should live.
ice
"Edward J. Stembler" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
|
| |
|
| |
|
|
| |
| Dilip Krishnan |
You would proably need to have a sponsor to renew the lifetime of the remoting server object
Chris Soulsby wrote:
[Original message clipped]
-- Regards, Dilip Krishnan MCAD, MCSD.net dilipdotnet at apdiya dot com
|
|
|
| |
|
| |
|
|
|
|
|