A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
Hi @Peter Liang ,
Thanks for reaching out.
From the screenshot, this looks like a .NET MAUI app rather than an ASP.NET app. The key clues are the App : Application class, the CreateWindow(...) override, and the project target showing something like net10.0-android. In MAUI, InitializeComponent() is generated from the matching XAML file, so this error usually means that link was not created correctly.
To resolve it, please check the following:
- Make sure you have an
App.xamlfile in the project. - In
App.xaml, confirm that thex:Classvalue exactly matches the namespace and class name inApp.xaml.cs. For example, if your code-behind isnamespace MauiApp10; public partial class App : Application, thenApp.xamlshould have:xml x:Class="MauiApp10.App" - Make sure
App.xaml.csis declared aspartial. - Verify that the build action for
App.xamlis set toMauiXaml. - Clean the solution, delete the
binandobjfolders, then rebuild the project.
If your project is truly ASP.NET or ASP.NET Core, then this App.xaml.cs / InitializeComponent() pattern does not belong there, and the application should instead be configured through Program.cs. In that case, the fix would be to remove this MAUI/XAML-based code from the web project.
Based on the screenshot though, the most likely fix is to restore or correct the App.xaml to App.xaml.cs mapping, then rebuild.
Hope this helps! If my answer was helpful, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.