this is a last resort after many days googling to try to find a definitive answer to my question.
I have created a Windows service, a Windows form, and a Remoting object (all in C#). I am using the Remoting object to communicate between the service and the form, using events.
Here's a simplified example of the typical interaction between the objects:
- AdminForm calls RemoteObject's method RequestLoadForm()
- RemoteObject fires off an event, that the AdminService is listening for
- AdminService is alerted of the event, and calls LoadFormData(string data) on the RemoteObject
- RemoteObject fires off an event, that the AdminForm is listening for
- AdminForm is alerted of the event, and can use the string data to set values on the AdminForm's controls
This all works fine, everything interacts beautifully for the first 5 minutes or so. After that, the connection between the objects gets severed somehow, and I can no longer communicate between objects.
First attempt at fixing the problem was to overwrite the InitializeLifetimeService method to return null. This didn't help (although it may avoid any future lease issues).
Second attempt was to make my AdminForm and AdminService ISponsors of the RemoteObject, and set them to renew the lease on the object. Once again, did not fix the issue.
In my various googlings I found someone mentioning something about event handlers being garbage collected. I'm not sure if that is the issue or not, but I thought I would mention it.
This is the error that pops up after the connection has been idle for > 5 minutes:
System.Runtime.Remoting.RemotingException was unhandled by user code
Message="Requested Service not found"
Source="System.Runtime.Remoting"
Now, the weird thing about this is that it occurs on the AdminService side. The AdminForm calls the method on the RemoteObject fine. This pops the event, and then the AdminService sees this event, and attempts to call the RemoteObject's method LoadFormData(string data), and this is where the exception is thrown.
I'm completely exhausted from google searches, since I cannot seem to find what I need to fix it.