WinUI-Gallery: Cannot create instance of type 'Microsoft.UI.Xaml.Controls.XamlControlsResources' [Line: 22 Position: 40] in App.g.i.cs

Bug Description: After downloading the sample, I try to run it with VS 2017 v. 15.9.18 in debug mode on x64 platform (Local machine). The debugger breaks in App.g.i.cs on line 53:

if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();

From the debugger watch I see, that this is Windows.UI.Xaml.Markup.XamlParseException. The exception message says: Cannot create instance of type ‘Microsoft.UI.Xaml.Controls.XamlControlsResources’ [Line: 22 Position: 40]

Exception sender is AppUIBasics.App. After taking a look at the XAML code of this code module on line 22, I see that this line of code: <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/> tries to instantiate “XamlControlsResources” which cannot be found.

However, when I go to NuGet Package manager, I see, that I do have Microsoft.UI.Xaml installed - version 2.3.191211002.

Steps to reproduce the bug Just downloaded the source, opened in VS 2017 and hit F5 with “Debug” build configuration, “x64” platform (Local machine).

Expected behavior Do not throw an exception.

Actual behavior An exception is thrown.

Screenshots

Version Info

I run Win 10 Pro, v. 1909

Gallery version (found on Settings page): I’m not sure what a gallery is.

Windows 10 version: I keep OS updated.

Device form factor:

  • Desktop
  • Mobile
  • Xbox
  • Surface Hub
  • IoT

Does anyone have any idea how to resolve this? Thank you.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Maybe this is a problem with WinUI or the package dependency resolvement itsself, there is also an ongoing issue over at WinUI regarding apps crashing for the same reason.

See the following issues on the WinUI repo for context:

https://github.com/microsoft/microsoft-ui-xaml/issues/999 https://github.com/microsoft/microsoft-ui-xaml/issues/616

Does the app also crash for you when running in Release and not in Debug? Maybe this is also an issue with VS as indicated by this comment by @jevansaks .

FYI, another workaround for those who don’t want to upgrade from VS2017 to VS2019: Install VS2019 then uninstall it, then it will work again in your VS2017 😂

PS: we also have similar issue w/ Win2D and this workaround works like magic 🙂

Hi @vlad-gregor - thank you for following up. On one hand, it’s unfortunate that we’re unable to get to the bottom of the issue, but on the other hand, VS2019 is the current version so I’m glad the issue no longer occurs. Closing this issue.