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(p => { App.Log("Application.Start callback enter"); var ctx = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread()); SynchronizationContext.SetSynchronizationContext(ctx); App.Log("SyncContext set — creating App"); var app = new App(); App.Log($"App instance created ({app.GetType().Name})"); }); App.Log("Application.Start returned"); } catch (Exception ex) { App.Log($"Main FAILED: {ex}"); throw; } } }