.NET MAUI使用Microsoft.Maui.Controls.Maps触发未处理异常
.NET MAUI地图控件添加后触发App.g.i.cs未处理异常
我在.NET MAUI应用中尝试实现地图功能,使用Microsoft.Maui.Controls.Maps提供的地图控件,但将该控件添加到XAML视图后,总是会在生成文件App.g.i.cs中触发未处理异常。
我已在.NET 6和.NET 7环境中进行尝试,均无法正常运行。使用的库版本如下:
- Microsoft.Maui.Controls.Maps => 7.0.49
- Microsoft.Maui.Maps => 7.0.49
我多次尝试更改库版本及运行时环境,但问题仍未解决。
触发异常的XAML视图源代码
<?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>
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(); } }
内容的提问来源于stack exchange,提问作者VonVega
相关产品推荐
相关产品推荐

