There is no magic way to check if the WCF service is running, other than calling and being prepared to handle exceptions that occur if they are not running.
ICommunicationObject.State will inform you that the channel between the client and the server is “faulty” if the previous operation resulted in an error and this error was not properly processed on the server (and thus the channel was “faulty”, for example, useless).
You can - if you control both ends of the wire - enable the ping "dummy" method (or something like returning the version number of the service) to be able to call something like that first, so just look, the channel is still alive.
But then: what is the real use of the first call to MyService.Ping() and the need to handle possible exceptions if the service is not alive and then calls your actual method, and not just calls MyService.MyMethod() and handles any relevant exceptions?
marc_s
source share