6

I have an app that works ok on the device emulator but on the real device it crashes after some time. It can happen after some minutes as well after 1-2 hours. The problem happens both with the device alone or attached to visual studio.

The point is that no exception is being thrown, VS just reports the connection was lost. I did check if i'm using too much memory but that's not the case (http://stackoverflow.com/questions/4239193/whats-causing-my-wp7-app-to-crash).

What can cause apps to crash without throwing exceptions?

Zmaster
  • 1,095
  • 9
  • 23

4 Answers4

4

It can crash without a visible exception on a Stackoverflow.

While debugging, you can detect such an exception by adding an event handler to Application.UnhandledException and writing the exception details in the Debug.WriteLine method. The result is visible in the Visual Studio Output / Debug window.

    private void OnAppUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
    {
        Debug.WriteLine(e.ExceptionObject.ToString());
    }
Community
  • 1
  • 1
thumbmunkeys
  • 20,606
  • 8
  • 62
  • 110
  • Does this apply to WP7 only? Because last year I was debugging an app that did crash due to a StackOverflowException and VS did just break like with any other unhandled exception. – Zmaster May 23 '11 at 18:12
  • according to the link there is no exception thrown on stackoverflow since c# 2.0 – thumbmunkeys May 23 '11 at 18:14
  • I just did test this. On .NET 4, StackOverflowException is thrown and even if not catched by the try/catch statement, VS breaks. On a WP7 application the app crashes and VS loses connection. Seems that i should work in this direction :) – Zmaster May 23 '11 at 18:30
  • 2
    Experienced this today. Took 2 hours to find-out. Stackoverflows on WP7 (emulator or device) are not caught by the debugger at all. The app and the debugger both crash when it occurs. – SandRock Mar 09 '12 at 08:30
2

You could get a crash that isn't caught if it happens on a non-UI thread. Check your async calls.

Also, any error in code that is executed in response to an action on an application bar button item or menu item could have cause this behaviour.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
1

It could be that the phsycal device does not exactly match the emulation configuration. You may be sending an error to a output stream that does not exist on the device, or sending it to something that is local for the emulator and remote for the device.

Also, you may just be satisfying different conditions that bring you to a clean exit.

The emulator is probably running clean compared to all the background applications on many devices.

Logging and debuging are your friends.

Your question is interesting but lacks detail.

Robolulz
  • 178
  • 1
  • 7
0

I have had a few instances of invalid xaml crashing the app.

You can change the settings in visual studio for exceptions to break on all exceptions to track down what is happening.

Luke Lowrey
  • 3,203
  • 3
  • 28
  • 40