Im trying to add some exceptionhandling in my win 8.1 universal app. From what I undersatnd from reading here at the forum I should be able to add for examlple something like this in my App.xaml.cs:
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
LogUnhandledException((Exception) e.ExceptionObject, "AppDomain.CurrentDomain.UnhandledException");
or: (from msdn)
// Add the event handler for handling UI thread exceptions to the event.
Application.ThreadException += new ThreadExceptionEventHandler(ErrorHandlerForm.Form1_UIThreadException);
// Set the unhandled exception mode to force all Windows Forms errors to go through
// our handler.
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
The problem is that i cannot acess either AppDaomain
or Application.ThreadException in my App.xaml.cs-file.
Does anyone knows what i am missing here? Thanks a lot!
EDIT:
From what I read in this thread :
http://stackoverflow.com/questions/13636751/is-there-a-global-exception-handler-in-windows-store-apps
This seems to be a way to do something similar:
public App()
{
this.InitializeComponent();
this.Suspending += this.OnSuspending;
this.UnhandledException += App_UnhandledException;
}
void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
//This method never seems to get hit
}
However,it does not seem to be enough, the methid never gets hit. Does this mean that there are no exceptions occuring?