Reputation: 21
I need to get operating maps in my .NET MAUI app so i tried to use the maps from "Microsoft.Maui.Controls.Maps" but when i add the map control to the XAML it always trigger a breakpoint in generated file called "App.g.i.cs"
This is the source code of the XAML view that always throw that unhandled exception
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:maps="clr-namespace:Microsoft.Maui.Controls.Maps;assembly=Microsoft.Maui.Controls.Maps"
x:Class="RecargaEle.MainPage">
<ScrollView>
<VerticalStackLayout>
<maps:Map/>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
I have tried this in .NET 6 and .NET 7 and it does not work in either of them...
The version of the libraries are: Microsoft.Maui.Controls.Maps => 7.0.49 Microsoft.Maui.Maps => 7.0.49
I tried to change the version of the library multiples times and change the runtime and none of this have worked
EDIT: I'll add here the MauiProgram.cs
using CommunityToolkit.Maui;
using RecargaEle.Service.Implementacion;
namespace RecargaEle;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.UseMauiMaps()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
builder.Services.AddSingleton<PuntosRecargaService>();
return builder.Build();
}
}
Upvotes: 2
Views: 1287
Reputation: 122
I used Windows to execute the application. If i execute it on an Android device or an Emulator, everything works fine.
As @Gerald Versluis mentioned in the Commentsection:
Well for Windows this error message is "correct". WinUI, the underlaying platform for .NET MAUI on Windows does not have a map control and as such, we're unable to implement it. We're working on a Windows one in the .NET MAUI Community Toolkit to have some solution: github.com/CommunityToolkit/Maui/pull/604 It should work fine on other platforms. This error is expected for Windows
Upvotes: 0