Hello there,
To prevent the app from crashing due to unhandled exceptions, it's a good practice to implement global exception handling. In your App.xaml.cs file, you can subscribe to the UnhandledException event to catch and handle exceptions before they crash the app.
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
this.UnhandledException += App_UnhandledException;
}
private void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
{
// Handle the exception here, e.Exception provides the exception details
e.Handled = true; // Set to true to indicate that the exception has been handled
}
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer--
UWP app: An unhandled exception is thrown on every launch
Alexander Kvitko
41
Reputation points
Every time I changed the xaml markup in my UWP app, I was getting an unhandled exception and I couldn't run my app in Visual Studio 2022. Now I get this unhandled exception every time I run the app, I need to remove the app build and do rebuild in VS to launch the application. What could be wrong or where could be the error?
Developer technologies | Universal Windows Platform (UWP)
3,038 questions
Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | XAML
857 questions
1 answer
Sort by: Most helpful
-
Limitless Technology 44,766 Reputation points
2023-08-16T10:45:23.6733333+00:00