views:

40

answers:

1

Greetings, I am developing some appliacation in WPF. Client is written in WPF, service in WCF. There is a case when client looses connection to the server (because of the internet issues). Then he have the following error: "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state." and the application shutdown. After this message is shown and client clicks "OK" on the messagebox the aplications closes. I don't want it the be closed. How can I do this? I am using ClickOnce deployment if this will help, each time client runs the application it searching for new version. I am handling exception in the following way when creating channel

try
        {

            Response response = Channel.ProcessRequest(request);
            return response;
        }
        catch (Exception ex)
        {
                MessageBox.Show(ex.Message.ToString());
            return null;
        }
        finally
        {

        }
+1  A: 

It seems like your blanket exception handler is doing the trick. You're catching the error and displaying it to the user. However, you're returning null. Without seeing any other code, I can only guess is that the caller doesn't appreciate getting a null response and the app dies, although I would expect an unhandled exception. But upstream you could also have another try/catch block that is silently ignoring this exception. No one can tell you unless you provide more details.

Dave