In java we have Thread.UncaughtExceptionHandler for handling the unhandled exceptions. How can I handle the unhandleded exception in C# UWP.
I am unable to use the AppDomain as it is not supported. Also, there are some references around Assemblies. Is there any example or document I can refer to ?
Thank you
Since I am new with C#, I am finding it hard to implement using the details in that documentation. I found one link as follows, but that is not usable for UWP. msdn.microsoft.com/en-us/library/… An equivalent of the above documented example will be very helpful for me.
If you create a new blank UWP project, you will find the App.xaml.cs
file. Open it and register the UnhandledException
event for your app like the following:
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
this.UnhandledException += App_UnhandledException;
}
private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
//TODO:
}
....
}
Since you said that you're new with c#, what you need to do is to learn some c# basic technology at first. For example, How to: Subscribe to and Unsubscribe from Events (C# Programming Guide)