I have a problem with building a .NET MAUI app.
When I build the app I get this error message:
Severity Code Description Project File Line Suppression State Error XLS0414 The type ‘maui:MauiWinUIApplication’ was not found. Verify
that you are not missing an assembly reference and that all referenced
assemblies have been built.
Screenshot: ‘maui:MauiWinUIApplication’ was not found
And this one:
Severity Code Description Project File Line Suppression State Error CS1061 ‘App’ does not contain a definition for ‘InitializeComponent’
and no accessible extension method ‘InitializeComponent’ accepting a
first argument of type ‘App’ could be found (are you missing a using
directive or an assembly reference?) Qit.QtimeUniversal.MAUI
(net7.0-windows10.0.22621.0)*
The problem is in the App.xaml (and App.xaml.cs) file of the Windows platform which is in the Targets/…/Platforms/Windows folder:
I also get this error:
*Severity Code Description Project File Line Suppression State Error WMC9999 Data at the root level is invalid. Line 1, position 2.
MSB4018 The "XamlCTask" task failed unexpectedly.
System.Xml.XmlException: Data at the root level is invalid. Line 1,
position 2.
in this file:
…..nugetpackagesmicrosoft.windowsappsdk1.2.221209.1buildTransitiveMicrosoft.UI.Xaml.Markup.Compiler.interop.targets file:
I saw a similar issue described here:
What I have tried so far:
- I have deleted all the bin and obj folder of all projects in the solution and then rebuild the solution. But this didn’t solve it.
- I have checked if the .csproj file of the project the app.xaml.cs file is in is corrupted. But I could not find anything.
- The build action of the app.xaml file is set to MauiXaml. I have changed this to build action: page , but this was not right and didn’t solve it. The build action is by default: MauiXaml if you create a new .NET MAUI app project in Visual Studio.
It might have something to do with a reference assembly which is not right.
But it used to work fine and now all for a sudden it failed to build.
Does anybody have an idea what might be the root cause of these issues?
2
Answers
I think I found the answer here: https://github.com/dotnet/maui/issues/5785
Screenshot
This solved this issue:
Now I can build the app again on Windows. On android I still get a build error though.
You should pay attention to the versions and whether they are x64 or x86.