[BUG] Won't run in VS in Unpackaged version
Describe the bug
Cloned the git Repo. Opened in latest VS 2022 17.14. Built the solution. Tried running under debugger in VS. It exits every time: The program '[28584] AIDevGallery.exe' has exited with code 2154233878 (0x80670016).
To Reproduce Steps to reproduce the behavior: Try running solution under Unpackaged profile inside of VS.
Expected behavior I should be able to debug the app under VS.
Please complete the following information:
- App Version: latest from GitHub
- Windows: 10.0.22621, win-x64
- DotNet 9
Managed to get it to run by adding:
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<WindowsPackageType>None</WindowsPackageType>
to csproj. But now it does not actually start and fails during XAML App initialization with System.InvalidOperationException originating in WinRT.Runtime.dll and debugger breaking in App.g.i.cs:
partial class App : global::Microsoft.UI.Xaml.Application {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.UI.Xaml.Markup.Compiler"," 3.0.0.2509")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public void InitializeComponent()
{
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
}
}
with the actual exception trackable to:
internal unsafe static void Start(IObjectReference _obj, global::Microsoft.UI.Xaml.ApplicationInitializationCallback callback)
{
IntPtr thisPtr = _obj.ThisPtr;
ObjectReferenceValue value = default(ObjectReferenceValue);
try
{
value = ApplicationInitializationCallback.CreateMarshaler2(callback);
ExceptionHelpers.ThrowExceptionForHR(((delegate* unmanaged[Stdcall]<IntPtr, IntPtr, int>)(*(IntPtr*)((nint)(*(IntPtr*)(void*)thisPtr) + (nint)7 * (nint)sizeof(delegate* unmanaged[Stdcall]<IntPtr, IntPtr, int>))))(thisPtr, MarshalInspectable<object>.GetAbi(value)));
}
finally
{
MarshalInspectable<object>.DisposeMarshaler(value);
}
}
AIDevGallery.dll!AIDevGallery.App.InitializeComponent.AnonymousMethod__27_2(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) Line 69 C# Symbols loaded.
Microsoft.WinUI.dll!WinRT._EventSource_global__Microsoft_UI_Xaml_UnhandledExceptionEventHandler.EventState.GetEventInvoke.AnonymousMethod__1_0(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) Line 22 C# Symbols loaded.
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.UnhandledExceptionEventHandler.Do_Abi_Invoke(nint thisPtr, nint sender, nint e) Line 177 C# Symbols loaded.
[Native to Managed Transition] Non-user code. Annotated Frame
[Managed to Native Transition] Non-user code. Annotated Frame
WinRT.Runtime.dll!WinRT.ExceptionHelpers.ReportUnhandledError(System.Exception ex) Line 450 C# Symbols loaded.
Microsoft.InteractiveExperiences.Projection.dll!Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.Post.AnonymousMethod__0() Unknown No symbols loaded.
Microsoft.InteractiveExperiences.Projection.dll!ABI.Microsoft.UI.Dispatching.DispatcherQueueHandler.Do_Abi_Invoke(nint thisPtr) Unknown No symbols loaded.
[Native to Managed Transition] Non-user code. Annotated Frame
[Managed to Native Transition] Non-user code. Annotated Frame
> Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(WinRT.IObjectReference _obj, Microsoft.UI.Xaml.ApplicationInitializationCallback callback) Line 33 C# Symbols loaded.
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback) Line 254 C# Symbols loaded.
AIDevGallery.dll!AIDevGallery.Program.Main() Line 40 C# Symbols loaded.
Is there a reason you're trying to run unpackaged over the packaged run? I would imagine the app needs to run as packaged for the identity needed for the Windows AI APIs (at minimum).
There was such a configuration, and since I do not use app store it felt natural to use that configuration. Since it's in the solution I thought it ought to be supported - for the APIs that do not require strong App Identity.