WpfApp2/WpfApp4/App.xaml.cs
2025-07-15 14:21:59 +02:00

31 lines
1.1 KiB
C#

using System;
using System.Windows;
namespace FahrzeugVerwaltung
{
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
DispatcherUnhandledException += App_DispatcherUnhandledException;
}
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show($"Ein unerwarteter Fehler ist aufgetreten:\n{e.Exception.Message}",
"Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
e.Handled = true;
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
MessageBox.Show($"Ein kritischer Fehler ist aufgetreten:\n{((Exception)e.ExceptionObject).Message}",
"Kritischer Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}