Hello,
I have checked out your Github repository and noticed the development is still going on.
I also noticed you are still using .NET MAUI 8, which is out of support. I’d strongly suggest upgrading to .NET MAUI 9 or later to keep things running smoothly with the latest support and improvements.
Regarding the issue, an unhandled exception happens when an error pops up in your app that isn’t caught by a try...catch block, which can cause a crash. Since I don’t have the specifics on the exact exception you’re seeing, I’ll walk you through some steps to track it down and fix it.
1. Set Up a Global Exception Handler
To catch these unhandled exceptions before they crash your app, you can add a global exception handler. This will log the error details and even let you show a friendly message to your users. For example:
public App()
{
InitializeComponent();
// Catch unhandled exceptions for the app domain
AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
{
var exception = eventArgs.ExceptionObject as Exception;
System.Diagnostics.Debug.WriteLine($"Unhandled exception: {exception}");
// Show a user-friendly alert
MainPage.DisplayAlert("Error", "Something unexpected happened.", "OK");
};
// Catch unobserved task exceptions
TaskScheduler.UnobservedTaskException += (sender, eventArgs) =>
{
var exception = eventArgs.Exception;
System.Diagnostics.Debug.WriteLine($"Unobserved task exception: {exception}");
eventArgs.SetObserved(); // Prevents crashes
};
MainPage = new AppShell();
}
2. Check the Output Window in Visual Studio
When you’re debugging in Visual Studio, keep an eye on the Output window. It’ll show you the exception details, like the type, message, and stack trace.
3. Add try...catch Blocks
For parts of your code that might fail—like network calls, file operations, or parsing data—wrap them in a try...catch block.
try
{
// Example: A network call that might fail
var result = await MyWebService.GetDataAsync();
}
catch (System.Exception ex)
{
// Log the error and let the user know
System.Diagnostics.Debug.WriteLine($"Error: {ex.Message}");
await MainPage.DisplayAlert("Error", $"Oops, something went wrong: {ex.Message}", "OK");
}
I hope this helps you with the issue.
References
You could also check out these resources for more details: