For unhandled exceptions, at least, I'd like to be able to catch the details and write them out to a file for potential subsequent "debugging forensics." There is no "OnTerminating" event in Windows store apps; is there a suitable place/way to accomplish such?
See my comment below. Here is an addition that won't fit below:
Even when removing the xaml snippet, I still get that err msg, and even after Cleaning and Rebuilding...??? 2-clicking the err msg just takes me to the top of App.xaml, the entirety of which is now:
<Application
x:Class="SpaceOverlays.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SpaceOverlays">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--
Styles that define common aspects of the platform look and feel
Required by Visual Studio project and item templates
-->
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
After closing App.xaml and rebuilding, all is well...??? Oh, well - all's well that ends well, I guess.
It's interesting that Windows Phone apps App.xaml.cs have this handler by default:
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
Debugger.Break();
}
}
Only one Global Exception Handler can be set per automation project. By default, the template retries the exception 3 times before aborting the execution. This default behavior can be changed from inside the template.
The operating system uses structured exception handling to signal certain kinds of errors. A routine called by a driver can raise an exception that the driver must handle. The system traps the following general kinds of exceptions: Hardware-defined faults or traps, such as, Access violations (see below)
Adding a Global Exception Handler The New Global Handler window opens. Type in a Name for the handler and save it in the project path. Click Create, a Global Exception Handler is added to the automation project.
Also, we identified that the global exception handler is a part of the Thread class and it handles the uncaught runtime exceptions. Then, we saw a sample program that throws a runtime exception and handles it using a global exception handler. The example codes for this article can be found over on GitHub.
For HTML5/JavaScript apps you have the onerror event as your last chance to capture info.
For XAML-based apps, you can use UnhandledException; however, that only captures exceptions that come up through the XAML (UI) framework and you don't always get a lot of information about what the root cause is, even in InnerException.
Update for Windows 8.1: UnhandledException also will capture exceptions that are created by an async void
method. In Windows 8, such exceptions would just crash the app. LunarFrog has a good discussion of this on their website.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With