I've wrote a piece of code similar to the example in this post: .NET Remoting callback (Pass a callback object to a remote method).
As I found out, if I didn't override MarshalByRefObject.InitializeLifetimeService()
After a while, the server failed calling the callback.
So I overriden it to return null (infinite lifetime) and it works.
But now I'm a bit worried about garbage collecton:
- Will such an object be collected by GC as usual, or remain alive because it was remoted?
- I found this method:
RemotingServices.Disconnect()
If I call it on my callback object, will it guarantee that the lifetime policy will become irrelevant and it will be garbage collected?
I wanted an expert opinion if I'm doing it right.
Thanks, Gil.
PS. I'm working under the constraints of .NET 2.0, so recommendations to switch to WCF, while correct, are irrelevant. :)