SettingsControls 8.1.240821 produces trim warnings
Describe the bug
The app crashes during initialization.
Running under WinDbg reveales that the stowed exception is 0x80040154 (REGDB_E_CLASSNOTREG) with the following stack trace:
System_Private_CoreLib!System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32)+0x1b
WinRT_Runtime!WinRT.ActivationFactory.Get(System.String, System.Guid)+0x1aa
Microsoft_WinUI!Microsoft.UI.Xaml.Application.get__objRef_global__Microsoft_UI_Xaml_IApplicationStatics()+0x6b
Microsoft_WinUI!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback)+0x19
Expander_MRE!Expander_MRE.Program.Main(System.String[])+0xe4
Steps to reproduce
Create a new project from the "Blank App, Packaged (WinUI 3 in Desktop)" template and add
* CsWinRT `2.1.1`
* WindowsSdkPackageVersion `10.0.22621.38` (matching `TargetFramework`)
* SettingsControls 8.1.240821
(ensure WASDK is at version `1.6.240829007`, this was already the case for me)
Then,
1. Add `<controls:SettingsExpander />` to `MainWindow.xaml`
2. Start the project in release mode (the template included publish profile enables `PublishedTrimmed` for release builds)
3. Crash on startup
Expected behavior
There are no trim warnings, app does not crash on startup.
Screenshots
No response
Code Platform
- [ ] UWP
- [X] WinAppSDK / WinUI 3
- [ ] Web Assembly (WASM)
- [ ] Android
- [ ] iOS
- [ ] MacOS
- [ ] Linux / GTK
Windows Build Number
- [ ] Windows 10 1809 (Build 17763)
- [ ] Windows 10 1903 (Build 18362)
- [ ] Windows 10 1909 (Build 18363)
- [ ] Windows 10 2004 (Build 19041)
- [ ] Windows 10 20H2 (Build 19042)
- [ ] Windows 10 21H1 (Build 19043)
- [ ] Windows 10 21H2 (Build 19044)
- [ ] Windows 10 22H2 (Build 19045)
- [ ] Windows 11 21H2 (Build 22000)
- [X] Other (specify)
Other Windows Build number
Windows 11 23H2
App minimum and target SDK version
- [X] Windows 10, version 1809 (Build 17763)
- [ ] Windows 10, version 1903 (Build 18362)
- [ ] Windows 10, version 1909 (Build 18363)
- [ ] Windows 10, version 2004 (Build 19041)
- [ ] Windows 10, version 2104 (Build 20348)
- [ ] Windows 11, version 22H2 (Build 22000)
- [ ] Other (specify)
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
17.11.35222.181
Device form factor
Desktop
Additional context
Discovered this issue when trying to enable NativeAOT for my project, which seems to be blocked by this issue.
Although I'm unable to reproduce the behaviour in my MRE, my original project is able to render the expander, but throws the following exception when expanding it:
System.ExecutionEngineException
HResult=0x80131506
This exception was originally thrown at this call stack:
WinRT.ExceptionHelpers.ThrowExceptionForHR.__Throw|38_0(int)
ABI.Microsoft.UI.Xaml.Controls.IStyleSelectorMethods.SelectStyle(WinRT.IObjectReference, object, Microsoft.UI.Xaml.DependencyObject)
CommunityToolkit.WinUI.Controls.SettingsExpander.ItemsRepeater_ElementPrepared(Microsoft.UI.Xaml.Controls.ItemsRepeater, Microsoft.UI.Xaml.Controls.ItemsRepeaterElementPreparedEventArgs) in SettingsExpander.ItemsControl.cs
ABI.Windows.Foundation.TypedEventHandlerMethods<TSender, TSenderAbi, TResult, TResultAbi>.Abi_Invoke(System.IntPtr, TSender, TResult)
WinRT.GenericTypeInstantiations.Windows_Foundation_TypedEventHandler_2_Microsoft_UI_Xaml_Controls_ItemsRepeater__Microsoft_UI_Xaml_Controls_ItemsRepeaterElementPreparedEventArgs.Do_Abi_Invoke(System.IntPtr, System.IntPtr, System.IntPtr)
Inner Exception 1:
InvalidCastException: Specified cast is not valid.
Help us help you
Yes, but only if others can assist.
@vilgotf 8.1 was built against 1.5 and hasn't been tested against AOT scenarios yet. You'll at least want the 1.6 bits on our preview feeds: https://aka.ms/wct/wiki/previewpackages
See https://github.com/CommunityToolkit/Tooling-Windows-Submodule/issues/205
I am seeing SettingsControls failing to parse XAML when under AOT. Is there a timeline to update this control to be AOT compatible?
WindowsAppSDK 1.6.241114003
CommunityToolkit.WinUI.Controls.SettingsControls 8.1.240916
@vilgotf @TheJoeFin I'm going to close this one out as it was specifically about 8.1 which is NOT AOT compatible (as I mentioned above); 8.2 will be the first version that's AOT compatible with WASDK 1.6. There was another issue filed, where I commented that I have not seen an issue with it working there. https://github.com/CommunityToolkit/Windows/issues/568#issuecomment-2498695680
Please check your versions and try the latest preview to see if that works for you, thank you!