0

We did't have any Test team support for our Product Development. so. we need intercept and handle all Exception for improve User experience. is There have any Soluction in windows phone Application?

as Fllow in app.xaml.cs file. we found :

      // Code to execute on Unhandled Exceptions
    private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
    {
        if (e.ExceptionObject is QuitException)
            return;

        if (System.Diagnostics.Debugger.IsAttached)
           {
              // An unhandled exception has occurred; break into the debugger
              System.Diagnostics.Debugger.Break();
           }


        if (System.Diagnostics.Debugger.IsAttached)
        {
            // An unhandled exception has occurred; break into the debugger
            System.Diagnostics.Debugger.Break();
        }
    }

2 Answers 2

1

Yes, this should catch all the exceptions that you missed in your app. Considering that you obviously are not catching many exception somewhere else and are looking for a simple solution, this event handler might work, but I seriously don't recommend it.

This event handler catches the exceptions and then should crash/quit your app. If you handled your exceptions only here, this would lead to a huge crash count. Sometimes exceptions happen, but the app can continue working normally. That's why I recommend that you handle them as they happen in your code, and not here. That way you have a full control of how your app continues and if it continues at all, and reduce the number of "unhandled exceptions" and app crashes.

5
  • we have been handle them ahout our code. just in case. we need get all Exception information . so we have to make sure intercept all of them . it will be crash in your suggestion.
    – kai chen
    Aug 9, 2012 at 7:33
  • if you need to collect the information about the unhandled exceptions, use the event you mentioned (you can even use something called Little Watson to email yourself the exceptions that happen unexpectedly blogs.msdn.com/b/andypennell/archive/2010/11/01/…
    – Igor Ralic
    Aug 9, 2012 at 7:39
  • Thanks. we want intercept all Exception information and use EmailTask send to server.
    – kai chen
    Aug 9, 2012 at 7:42
  • EmailTask is OK, but a user must send it from his or her email account. Sometimes, they are unwilling, but they are willing to POST it to your server so from there on you can email it to yourself. That's what Little Watson can be used for. Good luck!
    – Igor Ralic
    Aug 9, 2012 at 7:47
  • we have been try. we made option when exception got be catched user can be choose。 just as you say. record all exception log and post it to server.
    – kai chen
    Aug 9, 2012 at 7:51
0

Put your code in Try-Catch Block. I was also facing such problem, but then handled by Exception Handling Method.

 try
  {
   // your code
  }

 catch (Exception ex)
  {

    throw (ex);
  }
1
  • let's make it easy. i just want use some code catch all exception when appliction is run. even if use can use it and it can't crash unexpected。
    – kai chen
    Oct 22, 2013 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.