I've got a GUI client which is running against a WCF services hosted as a Windows service on a server box. The WCF service is running in PerCall InstanceContextMode, and the client has a singleton instance of the service client and I want to avoid reinstantiating the singleton on every call as it makes life difficult for the many asynchronous calls I have.
The problem for me is, after the Windows service is restarted, everytime the client makes a call it gets an exception message like this:
This channel can no longer be used to send messages as the output session was auto-closed due to a server-initiated shutdown. Either disable auto-close by setting the DispatchRuntime.AutomaticInputSessionShutdown to false, or consider modifying the shutdown protocol with the remote server.
What's the best way to get around this? I can put try-catch clauses around all the calls to the service client and reinstantiate the singleton instance on communication exceptions but that will involve a lot of boilerplate code..