diff --git a/Needlework.Net/Program.cs b/Needlework.Net/Program.cs index 46c9a8c..38c1470 100644 --- a/Needlework.Net/Program.cs +++ b/Needlework.Net/Program.cs @@ -6,6 +6,7 @@ using Needlework.Net.ViewModels; using Projektanker.Icons.Avalonia; using Projektanker.Icons.Avalonia.FontAwesome; using System; +using System.IO; namespace Needlework.Net; @@ -15,8 +16,13 @@ class Program // SynchronizationContext-reliant code before AppMain is called: things aren't initialized // yet and stuff might break. [STAThread] - public static void Main(string[] args) => BuildAvaloniaApp() + public static void Main(string[] args) + { + AppDomain.CurrentDomain.UnhandledException += Program_UnhandledException; + + BuildAvaloniaApp() .StartWithClassicDesktopLifetime(args); + } // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() @@ -43,4 +49,9 @@ class Program var services = builder.BuildServiceProvider(); return services; } + + private static void Program_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + File.WriteAllText($"errorlog-{DateTime.Now:HHmmssfff}", e.ExceptionObject.ToString()); + } }