diff --git a/shell/windows/LayersShell/App.xaml.cs b/shell/windows/LayersShell/App.xaml.cs index 109b776..7fd773e 100644 --- a/shell/windows/LayersShell/App.xaml.cs +++ b/shell/windows/LayersShell/App.xaml.cs @@ -13,11 +13,13 @@ public partial class App : Application Log("App ctor enter"); try { - InitializeComponent(); + AppDomain.CurrentDomain.FirstChanceException += (_, e) => + Log($"FirstChance: {e.Exception.GetType().Name}: {e.Exception.Message}"); AppDomain.CurrentDomain.UnhandledException += (_, e) => Log($"UnhandledException: {e.ExceptionObject}"); UnhandledException += (_, e) => Log($"XAML UnhandledException: {e.Exception}"); + InitializeComponent(); Log("App ctor ok"); } catch (Exception ex) diff --git a/shell/windows/LayersShell/LayersShell.csproj b/shell/windows/LayersShell/LayersShell.csproj index 836bb76..f39d3aa 100644 --- a/shell/windows/LayersShell/LayersShell.csproj +++ b/shell/windows/LayersShell/LayersShell.csproj @@ -11,6 +11,7 @@ true None true + $(DefineConstants);DISABLE_XAML_GENERATED_MAIN enable latest true diff --git a/shell/windows/LayersShell/Program.cs b/shell/windows/LayersShell/Program.cs new file mode 100644 index 0000000..2954758 --- /dev/null +++ b/shell/windows/LayersShell/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.Threading; +using Microsoft.UI.Dispatching; +using Microsoft.UI.Xaml; + +namespace LayersShell; + +public static class Program +{ + [STAThread] + static void Main(string[] args) + { + App.Log($"Main enter (args={args.Length})"); + try + { + WinRT.ComWrappersSupport.InitializeComWrappers(); + App.Log("ComWrappers initialised"); + Application.Start(_ => + { + App.Log("Application.Start callback enter"); + var ctx = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread()); + SynchronizationContext.SetSynchronizationContext(ctx); + App.Log("SyncContext set — creating App"); + _ = new App(); + App.Log("App instance created"); + }); + App.Log("Application.Start returned"); + } + catch (Exception ex) + { + App.Log($"Main FAILED: {ex}"); + throw; + } + } +}