using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using System.Windows; namespace PEP_Tool { /// /// Interaktionslogik für "App.xaml" /// public partial class App : Application { void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { // Process unhandled exception LogFile.WriteLine($"{Environment.NewLine} UnhandledException: {Environment.NewLine + e.Exception}"); e.Handled = true; } private void Application_Startup(object sender, StartupEventArgs e) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); //FirstChanceEx(); } void FirstChanceEx() { AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) => { LogFile.WriteLine(eventArgs.Exception.ToString()); }; } void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception ex = e.ExceptionObject as Exception; LogFile.WriteLine($"{Environment.NewLine} UnhandledException: {Environment.NewLine + ex.ToString()}"); //MessageBox.Show(ex.Message, "Uncaught Thread Exception", MessageBoxButton.OK, MessageBoxImage.Error); } static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { // Log the exception, display it, etc LogFile.WriteLine(e.Exception.Message); } private void Application_Exit(object sender, ExitEventArgs e) { PEP_Tool.Properties.Settings.Default.Save(); } } }