James,
When you get the reference to the client, you have an object that
derives from MarshalByRefObject. With that, you can call GetLifeTimeService
which will return an object. This object can be cast to an ILease instance
which you would then query to get the state of the connection back to the
client. If the state indicates that it is not connected (or an exception is
thrown), then you can try and unsubscribe through the ILease interface, and
proceed from there.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> OK, after lots of faffing I have finally gotten remoting working -
> basically I have a windows service (the "server") and a forms app (the
[quoted text clipped - 24 lines]
>
> James.
Efrain Ruiz - 29 Feb 2008 00:43 GMT
I am having the EXACT problem with a chat system I have running. As long
as the clients logoff via the proper ways such as FILE | EXIT or
clicking the top right X button, everything is fine and dandy.
As soon as the client crashes or is shutdown via the Task Manager, the
server shoots an error message saying this:
"An existing connection was forcibly closed by the remote host"
After this, the server does not close the connection nor removes the
client from it's client list.
Only way to get everything back to normal, is to shutdown the server and
restart it.
Anyway to fix this, please?
Tommaso Caldarola - 29 Feb 2008 10:09 GMT
> I am having the EXACT problem with a chat system I have running. As long
> as the clients logoff via the proper ways such as FILE | EXIT or
[quoted text clipped - 12 lines]
>
> Anyway to fix this, please?
My solution (a SAO creates a CAO for each connection) is based on this
article (http://www.codeproject.com/KB/IP/remotingandevents.aspx).
I have customized the second solution implementing a ping method called
by the server, if the call throws an exception (no connection) I remove
the client (disposing the CAO).
JamesB - 07 Mar 2008 17:06 GMT
>> I am having the EXACT problem with a chat system I have running. As long
>> as the clients logoff via the proper ways such as FILE | EXIT or
[quoted text clipped - 18 lines]
> the server, if the call throws an exception (no connection) I remove the
> client (disposing the CAO).
I'll look through that - I made a slight bit of headway by sending my
messages async so if a client has disconnected "dirtily", the other
client(s) still receive messages. But I'm pretty sure that's going to lead
to memory leaks and gawd knows what, so the above will be my next bit o'
reading...