using System; using System.IO; using Microsoft.UI.Xaml; namespace LayersShell; public partial class App : Application { private MainWindow? _window; public App() { Log("App ctor enter"); try { InitializeComponent(); AppDomain.CurrentDomain.UnhandledException += (_, e) => Log($"UnhandledException: {e.ExceptionObject}"); UnhandledException += (_, e) => Log($"XAML UnhandledException: {e.Exception}"); Log("App ctor ok"); } catch (Exception ex) { Log($"App ctor FAILED: {ex}"); throw; } } protected override void OnLaunched(LaunchActivatedEventArgs args) { Log("OnLaunched enter"); try { _window = new MainWindow(); Log("MainWindow constructed"); _window.Activate(); Log("MainWindow activated"); } catch (Exception ex) { Log($"OnLaunched FAILED: {ex}"); throw; } } internal static void Log(string line) { try { var path = Path.Combine(Path.GetTempPath(), "layers-shell.log"); File.AppendAllText(path, DateTime.Now.ToString("HH:mm:ss.fff ") + line + Environment.NewLine); } catch { } } }