I get some errors when I want to replace Xamarin.Forms with Microsoft.Maui.Essentials. Can I use Microsoft.Maui.Essentials instead?

Kim Strasser 1,321 Reputation points
2022-12-30T16:48:21.157+00:00

I use the MonoGame 3.8.1.303 template to create my Android project, not the MAUI template in Visual Studio. And I set UseMauiEssentials to true in my Android csproj file so that I can use Microsoft.Maui.Essentials. But the problem is that I get some errors after removing the NuGet package Xamarin.Forms from my project.

 Xamarin.Forms.Forms.Init(this, bundle);  

Error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' (are you missing an assembly reference?)

 if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS)  

Error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' (are you missing an assembly reference?)

CurrentAppVersion = AppInfo.VersionString;  
CurrentAppBuild = AppInfo.BuildString;  

Error CS0103: The name 'AppInfo' does not exist in the current context

I use Target Android version 13.0 (API level 33). Is it still necessary to use Xamarin.Forms or can I use Microsoft.Maui.Essentials to solve these errors?

275133-bildschirmfoto-2022-12-28-um-140329.png

Developer technologies .NET .NET MAUI
{count} votes

1 answer

Sort by: Most helpful
  1. Kim Strasser 1,321 Reputation points
    2023-01-03T21:28:30.183+00:00

    It works now. I have added UseMaui to my Android csproj file:

    <Project Sdk="Microsoft.NET.Sdk">  
      <PropertyGroup>  
        <TargetFramework>net6.0-android33.0</TargetFramework>  
        <SupportedOSPlatformVersion>30.0</SupportedOSPlatformVersion>  
        <OutputType>Exe</OutputType>  
        <UseMaui>true</UseMaui>  
        <UseMauiEssentials>true</UseMauiEssentials>  
    

    Then Microsoft.Maui.Controls and Microsoft.Maui.Core are added to my project and I don't get the error System.IO.FileNotFoundException anymore.

    275833-bildschirmfoto-2023-01-03-um-132808.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.