'App' does not implement inherited abstract member 'MauiWinUIApplication.CreateMauiApp()'

Sam Wheat 361 Reputation points
2022-05-17T13:10:56.937+00:00

Error CS0534 'App' does not implement inherited abstract member 'MauiWinUIApplication.CreateMauiApp()' MyProject (net6.0-android) C:\Git\MyProject\obj\Debug\net6.0-windows10.0.19041.0\win10-x64\Platforms\Windows\App.g.i.cs 40 Active

AFAIK I have done nothing to change any android config items. I am trying to write a windows desktop app.

I created a new Maui project (it builds/runs fine) and compared the files and they appear to be identical other than project names.
There is no App.xaml in Platforms/Android in my project or the new app I created for comparison.
App.xaml.cs in Platforms/Windows does implement the abstract method:

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();  

How can I resolve this?

Visual Studio Info:

Microsoft Visual Studio Community 2022
Version 17.3.0 Preview 1.0
VisualStudio.17.Preview/17.3.0-pre.1.0+32505.426
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

.NET Core Debugging with WSL 1.0
.NET Core Debugging with WSL

ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 2019 17.3.122.33185
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0 17.3.122.33185
Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio 2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 17.3.122.33185
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 4.3.0-1.22254.1+9919d7e7bd753404a5d2328e5e3fb2de635169f3
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter 17.0.22115.6
Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft Azure Hive Query Language Service 2.6.5000.0
Language service for Hive query

Microsoft Azure Stream Analytics Language Service 2.6.5000.0
Language service for Azure Stream Analytics

Microsoft Azure Tools for Visual Studio 2.9
Support for Azure Cloud Services projects

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio 17.3.7 (c1ffb2a)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 6.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Python - Django support 17.0.22115.6
Provides templates and integration for the Django web framework.

Python - Profiling support 17.0.22115.6
Profiling support for Python projects.

Python with Pylance 17.0.22115.6
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Razor (ASP.NET Core) 17.0.0.2222701+751db1ebea5e6a9ecc7fa57fe447180422afa610
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.0.62204.01010
Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0
Hosting json editor into a tool window

TypeScript Tools 17.0.10420.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.3.0-1.22254.1+9919d7e7bd753404a5d2328e5e3fb2de635169f3
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.1.0-beta.22178.3+6da0245a7ce4bb8483b8d1f2993c8ecaea967ad9
Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog 1.0
Information about my package

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

VSPackage Extension 1.0
VSPackage Visual Studio Extension Detailed Info

Xamarin 17.3.0.91 (main@7802af5)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.3.0.30 (remotes/origin/main@fb6442dc1)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 17.2.15 (2e3b60e)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 12.3.99.58 (main/64b22fc)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: adf1bc4
Java.Interop: xamarin/java.interop/release/6.0.3xx@2a882d2d
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.38.2@7b1e016
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@fc3c2ac

Xamarin.iOS and Xamarin.Mac SDK 15.11.0.87 (406f3098e)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,903 questions
{count} votes

Accepted answer
  1. Michael Taylor 48,581 Reputation points
    2022-05-17T19:09:58.313+00:00

    I see the issue now. It appears that you originally created the project as LeaderPivot.XAML.MAUI.Host.WinUI. That means the namespace used to generate the code was the same. However you later started changing the classes to be in the LeaderAnalytics.LeaderPivot... namespace. So the generated code, which is using the original namespace, is not being merged into your partial classes you've defined and hence you're getting the errors. You need to sync up your namespaces of your types to what your XAML files are using.

    From what I can tell you should make at least the following changes:

    • platforms\windows\app.xaml change the x:class and xmlns:local attributes to use the updated namespace name.
    • platforms\windows\app.xaml change 'maui:MauiWinUIApplicationto justApplication`.
    • AppShell.xaml make the same changes.

    Now the auto-generated files (*.g.cs) should correctly merge with your codebehind files.

    1 person found this answer helpful.
    0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Sam Wheat 361 Reputation points
    2022-05-17T19:50:30.103+00:00

    Are you sure you are using the latest templates?? Please post your App.xaml and App.xaml.cs.

    https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-3/

    According to the above this is latest, generating AppShell, etc. I updated VS this weekend. I don't see versions for Maui Templates but the new objects being generated correspond to the blog post above.


  2. Sam Wheat 361 Reputation points
    2022-05-17T20:14:01.92+00:00

    Sorry but unless I am using outdated templates, your answer about namespaces is incorrect.

    It appears that you originally created the project as LeaderPivot.XAML.MAUI.Host.WinUI.

    Nope.

    Here are classes from project that builds and runs. Again, please note the WinUI namespace which is added by the template:

    Platforms/Windows/App.xaml

    <maui:MauiWinUIApplication
        x:Class="MauiApp1.WinUI.App"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:maui="using:Microsoft.Maui"
        xmlns:local="using:MauiApp1.WinUI">
    
    </maui:MauiWinUIApplication>
    

    Platforms/Windows/App.xaml.cs

    using Microsoft.UI.Xaml;
    
    // To learn more about WinUI, the WinUI project structure,
    // and more about our project templates, see: http://aka.ms/winui-project-info.
    
    namespace MauiApp1.WinUI;
    
    /// <summary>
    /// Provides application-specific behavior to supplement the default Application class.
    /// </summary>
    public partial class App : MauiWinUIApplication
    {
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
        }
    
        protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
    }
    

    App.xaml

    <?xml version = "1.0" encoding = "UTF-8" ?>
    <Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:local="clr-namespace:MauiApp1"
                 x:Class="MauiApp1.App">
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Resources/Colors.xaml" />
                    <ResourceDictionary Source="Resources/Styles.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    </Application>
    

    Appl.xaml.cs

    namespace MauiApp1;
    
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
    
            MainPage = new AppShell();
        }
    }
    

  3. Sam Wheat 361 Reputation points
    2022-05-17T20:34:56.617+00:00

    LeaderPivot... as the namespace. Your codebehind files are using LeaderAnalytics.LeaderPivot...

    THIS is the problem! I thought you were saying I was adding .WinUI... that is added by the template.

    Thank you, one millllyon stars for you today.