CommunityToolkit / Windows

Collection of controls for WinUI 2, WinUI 3, and Uno Platform developers. Simplifies and demonstrates common developer tasks building experiences for Windows with .NET.
https://aka.ms/windowstoolkitdocs
Other
550 stars 71 forks source link

PublishAot with Segmented control crash at runtime #536

Open 0x7c13 opened 4 days ago

0x7c13 commented 4 days ago

Describe the bug

These are the versions I am using (all up to date)
CommunityToolkit.WinUI.Controls.HeaderedControls" Version="8.1.240916" CommunityToolkit.WinUI.Controls.Primitives" Version="8.1.240916" CommunityToolkit.WinUI.Controls.RangeSelector" Version="8.1.240916" CommunityToolkit.WinUI.Controls.Sizers" Version="8.1.240916" CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240916" CommunityToolkit.WinUI.Controls.Segmented" Version="8.1.240916" CommunityToolkit.WinUI.Converters" Version="8.1.240916" CommunityToolkit.WinUI.Animations" Version="8.1.240916"

Microsoft.Windows.CsWinRT" Version="2.1.6" Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" Microsoft.WindowsAppSDK" Version="1.6.240923002"

And I set this in the csproj: PublishAot->True

For release build, as long as I click on a Page that contains Segmented control, it crashes. Maybe it has something to do with introducing xmlns:controls="using:CommunityToolkit.WinUI.Controls" in the xaml?

The error is very generic (like always:(): Failed to assign to property 'Microsoft.UI.Xaml.ResourceDictionary.Source' because the type 'Windows.Foundation.String' cannot be assigned to the type 'Windows.Foundation.Uri'.

Steps to reproduce

It should be easy to reproduce, just create a new app with PublishAot set to true. Add Segmented control to the home page and run under release mode.

Expected behavior

App should not crash.

Screenshots

No response

Code Platform

Windows Build Number

Other Windows Build number

Windows 11 24H2 (Build 26100)

App minimum and target SDK version

Other SDK version

<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>     <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>     <WindowsSdkPackageVersion>10.0.22621.38</WindowsSdkPackageVersion>

Visual Studio Version

2022

Visual Studio Build Number

No response

Device form factor

Desktop

Additional context

No response

Help us help you

No, I'm unable to contribute a solution.

0x7c13 commented 4 days ago

My feeling is that some resource files (used by Segmented) are trimmed as part of the AOT causing the runtime error.