This commit is contained in:
jess 2026-04-23 07:37:34 -07:00
parent 6cd523ce5c
commit 378b018d82
3 changed files with 39 additions and 1 deletions

View File

@ -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)

View File

@ -11,6 +11,7 @@
<EnableMsixTooling>true</EnableMsixTooling>
<WindowsPackageType>None</WindowsPackageType>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<DefineConstants>$(DefineConstants);DISABLE_XAML_GENERATED_MAIN</DefineConstants>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<PublishReadyToRun>true</PublishReadyToRun>

View File

@ -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;
}
}
}