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

WinUI Packaged projects throws Markup.XamlParseException: 'XAML parsing failed.' #6452

Open
1 of 2 tasks
strfast365 opened this issue Dec 9, 2021 · 9 comments
Open
1 of 2 tasks
Labels
area-Tooling area-XamlCompiler bug Something isn't working product-winui3 WinUI 3 issues team-Markup Issue for the Markup team

Comments

@strfast365
Copy link

strfast365 commented Dec 9, 2021

Describe the bug

Single-project MSIX throws Markup.XamlParseException: 'XAML parsing failed.' when using templated control from ClassLibrary referenced by dll.

Steps to reproduce the bug

Steps to reproduce:

  1. Create WinUI class library
  2. Add empty custom control to the project
  3. Create a new Single-project MSIX project
  4. Add a new reference to dll of the class library
  5. Add custom control from class library to MainWindow.xaml
  6. Run project

WinUIRes.zip

Expected behavior

You can also create a new solution with a separate packaging project and repeat step 3,4,5,6 - it works fine

Screenshots

No response

NuGet package version

No response

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

May 2021 Update (19043)

Additional context

No response

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Dec 9, 2021
@gabbybilka gabbybilka added the product-winui3 WinUI 3 issues label Feb 8, 2022
@StephenLPeters StephenLPeters added area-Tooling area-XamlCompiler team-Controls Issue for the Controls team team-Markup Issue for the Markup team and removed team-Controls Issue for the Controls team needs-triage Issue needs to be triaged by the area owners labels Mar 1, 2022
@StephenLPeters
Copy link
Contributor

@RealTommyKlein and @evelynwu-msft FYI

@jeromelaban
Copy link

A workaround for this issue is to add this to the library:

<PropertyGroup>
   <DisableEmbeddedXbf>false</DisableEmbeddedXbf>
</PropertyGroup>

Though I'm not sure why this is disabled in debug in the first place. Maybe it breaks some hot reload scenarios.

Digging deeper, it seems that this issue is related to the way XBFs are embedded in the PRI file. In debug, this property is set to false:

  <PropertyGroup Condition="'$(_OverriddenDisableXbf)' == 'false'">
    <DisableEmbeddedXbf>true</DisableEmbeddedXbf>
    <DisableEmbeddedXbf Condition="'$(Configuration)'!='Debug'">false</DisableEmbeddedXbf>
  </PropertyGroup>

causing XBF files to be generated on the side.

In this mode, and using EnablePreviewMsixTooling to true, additional library payload files (xbf or XAML) are not published to the resulting payload, causing the app to fail to load anything non-embedded referenced in the PRI properly. This is not happening with the .wapproj which copies the payload file properly.

@sam-wheat
Copy link

What is the status on this ticket please? Suggested workaround does not work - are there any others?

Thank you.

@dotMorten
Copy link
Contributor

dotMorten commented Apr 16, 2023

I don’t think this could work. You need to use either a project reference or pack your output as a nuget package and reference that to get the resources as well. The DLL alone doesn’t carry enough in itself. This was also a requirement in the UWP days

@sam-wheat
Copy link

or pack your output as a nuget package and reference that to get the resources as well.

@dotMorten In my case my control works fine when referenced as a project however when I create a nuget package and reference that instead I get "XAML parsing failed".

Why would it not work? Seems like the standard use case for nuget packages.

@dotMorten
Copy link
Contributor

@sam-wheat see the issue linked a few messages up. It takes a bit of hacking to get it to make a usable package

@Felix-CodingClimber
Copy link

Same problem here...

@pmmachado1971
Copy link

Hello. Same problem here. Anyone have a solution?
I need to develop and App that loads plugins that have WinUI 3 pages/windows and always get xaml parsing failed is dll loaded externely. If class library is referenced directly from the project everything works ok, but I need to allow others to develop plugins with user interface and load the dynamically.
Any help will be appreciated.

@haonanttt
Copy link

I've created a discussion thread giving the workaround about how to solve the 'XAML parsing failed.' issue in this case. The link is #10268.

In short, when generating the nuget package, we could either:

  1. Set DisableEmbeddedXbf property to false when packing a 'Debug' nuget package
    or
  2. Pack a 'Release' nuget package instead

The workaround is same to what @jeromelaban had mentioned, and in a similar issue #7830 I've tried it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tooling area-XamlCompiler bug Something isn't working product-winui3 WinUI 3 issues team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

10 participants