CommunityToolkit / CommunityToolkit/Windows
Native AOT: InvalidCastException when using GridSplitter
- Dominant language
- C#
- Stars
- 1.1k
- Forks
- 166
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
I'm seeing this crash reported on a device with `Windows 10.0.19045`. I wasn't able to reproduce it locally on a Windows 11 machine
```
System.InvalidCastException: Specified cast is not valid
at System.Runtime.RuntimeExports.RhUnbox2(MethodTable*, Object) + 0x3f
at CommunityToolkit.WinUI.Controls.GridSplitter.IsStarColumn(ColumnDefinition) + 0x53
at CommunityToolkit.WinUI.Controls.GridSplitter.OnDragHorizontal(Double) + 0xf9
at CommunityToolkit.WinUI.Controls.SizerBase.OnManipulationDelta(ManipulationDeltaRoutedEventArgs) + 0x11b
at ABI.Microsoft.UI.Xaml.Controls.IControlOverrides.Do_Abi_OnManipulationDelta_15(IntPtr, IntPtr) + 0x58
```
I'm using `CommunityToolkit.WinUI.Controls.Sizers 8.2.241112-preview1` in a .NET9 WinUI3 app that is compiled using Native AOT
### Steps to reproduce
I'm essentially only using a GridSplitter and adjusting Grid.Row and Grid.Column in code
```text
```
### Expected behavior
No crash
### 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)
- [x] Windows 10 22H2 (Build 19045)
- [ ] Windows 11 21H2 (Build 22000)
- [ ] Other (specify)
### Other Windows Build number
_No response_
### 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
_No response_
### Device form factor
_No response_
### Additional context
_No response_
### Help us help you
Yes, I'd like to be assigned to work on this item.
Contributor guide
Assessment
This issue has not been assessed yet.