skip to Main Content

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:

Screenshot: App.xaml

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:

https://stackoverflow.com/questions/77335022/the-type-or-namespace-name-mauiwinuiapplication-does-not-exist-in-the-namespac

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


  1. Chosen as BEST ANSWER

    I think I found the answer here: https://github.com/dotnet/maui/issues/5785

    I've seen this a couple of times and I think that is something that needs to be improved in Visual Studio. Notice in the top-right corner there is a dropdown that now says VisualLogger (net6.0-android) that means your editor now shows the code as it would be compiled on Android. Hence, it won't find the Windows specific stuff.

    Switch that dropdown to Windows and it should show fine.

    Screenshot

    This solved this issue:

    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. Qit.QtimeUniversal.MAUI C:DevQITQFSQtimeMobileMAUIQit.QtimeUniversalSolutionQit.QtimeUniversalSolutionPlatformsWindowsApp.xaml 1

    Now I can build the app again on Windows. On android I still get a build error though.


  2. You should pay attention to the versions and whether they are x64 or x86.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search