“XamlControlsResources” causes "XAML parsing failed" exception when launched without deployment.

Lerner, Eugene 1 Reputation point

After several years of development with WPF, I’m trying to learn WinUI hence my question may sound too primitive, sorry.

I created a new app using “Blank App, Packaged (WinUI in Desktop)” template; it contains a single button prompting to click it.
The solution, generated by Visual Studio 2019 Enterprise, contains two projects – Windows Application and Package. When the Package project is set as “Startup” the app gets deployed and runs OK. Problem arises when Windows Application project is set as “Startup” – execution hits hardcoded breakpoint in “App.g.i.cs” with "XAML parsing failed" exception:
UnhandledException += (sender, e) => {
if (global::System.Diagnostics.Debugger.IsAttached)

After some tinkering, I commented out this line:
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
added as a merged dictionary into the “Application.Resources” dictionary. Commenting this line out solved the problem – Windows Application now runs as Startup project as well as when double-clicked in Windows Explorer. However, adding other controls from “Microsoft.UI.Xaml.Controls” namespace found in the “Microsoft.WinUI, Version=” assembly, such as “DropDownButton” or “RadioButtons”, breaks it.

What is the cause for “Microsoft.UI.Xaml.Markup.XamlParseException”?
How to launch WinUI as a desktop application without deploying it first?

Thank you,


Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,699 questions
{count} votes