Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A class library with a ResourceDictionary will crash with AOT enabled #4730

Open
ghost1372 opened this issue Sep 18, 2024 · 0 comments
Open

Comments

@ghost1372
Copy link
Contributor

Describe the bug

I have a class library that contains some ResourceDictionaries which i refrence them into app.xaml

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
            <ResourceDictionary Source="ms-appx:///WinUICommunity.Components/Themes/Generic.xaml" />
            <ResourceDictionary Source="ms-appx:///WinUICommunity.LandingPages/Themes/Generic.xaml" />
            <ItemTemplates xmlns="using:WinUICommunity" />
        </ResourceDictionary.MergedDictionaries>
        <!--  Other app resources here  -->
    </ResourceDictionary>
</Application.Resources>

, When I activate the PublishAOT switch:

<PublishAOT>true</PublishAOT>

My app does not run in debug or release or publish mode at all.
In debug mode, I get the following exception

  Name Value Type
  Message "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'. [Line: 10 Position: 37]" string
Exception {"The text associated with this error code could not be found.\r\n\r\nFailed to assign to property 'Microsoft.UI.Xaml.ResourceDictionary.Source' because the type 'Windows.Foundation.String' cannot be assigned to the type 'Windows.Foundation.Uri'. [Line: 10 Position: 37]"} System.Exception {Microsoft.UI.Xaml.Markup.XamlParseException}

after removing my resource dictionary refrences from app.xaml My app runs without problems.

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
        </ResourceDictionary.MergedDictionaries>

    </ResourceDictionary>
</Application.Resources>

I also tried this with a new class library and an empty resource dictionary and issue exist

Steps to reproduce the bug

1.Create a New WinUI 3 Project
2.Make sure your BuildTools is 22621.3232 (latest build tools can not be launch in AOT)
3.Create a Class Library with a Resource Dictionary (Create a nuget package)
4.Add Class Library to Project
5.Add Resource Dictionary in App.xaml
6.Run app (Works fine)
7.Add <PublishAOT>true</PublishAOT>
8.Try to run app (app will be crash)

Expected behavior

App Should be Run/Launch without any issues

Screenshots

No response

NuGet package version

Windows App SDK 1.6.0: 1.6.240829007

Packaging type

Packaged (MSIX), Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022-preview, Visual Studio 2022

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant