question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XamlC error after upgrading Visual Studio / SDK 6.0.2

See original GitHub issue

After updating Visual Studio / SDK 6.0.2, I am seeing the following Xaml compiler errors in my WPF App:

XamlC error XFC0000 : Cannot resolve type "Application"
XamlC error XFC0000 : Cannot resolve type "Window".

I have isolated the cause of these errors to a package reference that references ‘Xamarin.Forms’. This package reference worked fine prior to installing the update.

Repro Steps

  1. Create a new WPF App.
  2. Add a package reference to ‘Xamarin.Forms’.
  3. XAML compiler can not resolve “Application” and “Window” types.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ThomasGoulet73commented, Mar 2, 2022

@ebussa This looks unrelated to WPF because the XAML files in your repro are WPF XAML files but the error says that Xamarin tries to compile the files (Which it can’t, hence the errors). So it looks like the Visual Studio update made Xamarin try to compile those WPF XAML files (Xamarin tries to compile every .xaml files by default). You can opt out of the default Xamarin compilation by setting EnableDefaultXamlItems to false in your csproj.

The point that I was trying to make in my previous comment wasn’t that you shouldn’t do it, it was that it wasn’t suppose to work in the first place. By default, WPF and Xamarin will both try to compile .xaml files so you need to disable the one that you don’t use in your project.

0reactions
ebussacommented, Mar 3, 2022

You can opt out of the default Xamarin compilation by setting EnableDefaultXamlItems to false in your csproj.

Thank you for that, it works!

...
    <EnableDefaultXamlItems>false</EnableDefaultXamlItems>
  </PropertyGroup>

I will create an issue with the third party package team and let them know about this change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NETSDK1045: The current .NET SDK does not support ...
Go to Tools > Options > Environment > Preview Features, and make sure that Use previews of the .NET Core SDK is checked....
Read more >
Visual Studio 2022 problem after upgrade to last version ...
This issue is caused not by the Visual Studio update from 17.2.5 to 17.2.6, but by the update from .NET SDK 6.0.301 to...
Read more >
Solution to Visual Studio 2022 messing up ...
The error shown when attempting to load the projects was: The project file cannot be opened. Unable to locate the .NET SDK. Check...
Read more >
Unable to locate the .NET SDK: The Reasons - Hamid Mosalla
In this post is about fixing the following error : "The project file cannot be opened. Unable to locate the .NET SDK" we'll...
Read more >
Error after upgrading to latest version of Visual Studio 2022 ...
[Solved]-Error after upgrading to latest version of Visual Studio 2022 and project is not being loaded-.net-core. Search. score:0. Download .NET SDK (6.0) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found