maui
maui copied to clipboard
UseMauiMaps doesn't work if called before ConfigureFonts
Originally posted by @K-Ketchup in https://github.com/dotnet/maui/issues/12320#issuecomment-1676661355
Maps wasn't working but a fix was found in MauiProgram.cs. Changed the file from
using Microsoft.Extensions.Logging;
namespace Dook;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiMaps() // <-----------------------------------
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
To
using Microsoft.Extensions.Logging;
namespace Dook
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.UseMauiMaps(); // <-----------------------------------
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
}
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
This fix doesnt work. I have one MAUI app with UseMauiMaps before configure fonts and I dont get a handler error and I have another MAUI App where I can put UseMauiMaps before or after configure fonts and it doesnt work either way.
Instead an earlier fix worked for me which was to uninstall nuget 8.03 and go back to 7.0.59
This workaround is no longer needed. I'm using Microsoft.Maui.Controls.Maps 7.0.101 with .Net 7 and UseMauiMaps can be called before ConfigureFonts.
Still facing this error with .NET 8 & Microsoft.Maui.Controls.Maps 8.0.3.
I'm getting "Cannot resolve symbol UseMauiMaps"
@pablodelolmo can you post a repro project to a public GitHub repo? And show the exact error you're getting?
@Eilon Apologies for the delay. I've re-checked and it was a problem of the framework I was using. It is working as expected. Thanks!
Alright then, I think it's OK to close this issue. If anyone else sees something similar in the future, please log a new issue and make sure you post your app as a public GitHub repo so that we can reproduce the issue.
Getting this in CommunityToolkit popup
{System.ArgumentNullException: Value cannot be null. (Parameter 'handler.Container') at System.ArgumentNullException.Throw(String paramName) at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName) at CommunityToolkit.Maui.Core.Handlers.PopupHandler.MapSize(PopupHandler handler, IPopup view) at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[CommunityToolkit.Maui.Core.IPopup, CommunityToolkit.Maui.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[CommunityToolkit.Maui.Core.Handlers.PopupHandler, CommunityToolkit.Maui.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in D:\a_work\1\s\src\Core\src\PropertyMapper.cs:line 172 at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in D:\a_work\1\s\src\Core\src\PropertyMapper.cs:line 47 at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in D:\a_work\1\s\src\Core\src\PropertyMapper.cs:line 82 at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 79 at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921 at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863 at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96 at CommunityToolkit.Maui.Views.PopupExtensions.CreatePopup(Page page, Popup popup) at CommunityToolkit.Maui.Views.PopupExtensions.CreateAndShowPopup[SpinnerPopup](Page page, SpinnerPopup popup) at CommunityToolkit.Maui.Views.PopupExtensions.ShowPopup[SpinnerPopup](Page page, SpinnerPopup popup) at popuploader.MainPage.OnCounterClicked(Object sender, EventArgs e) in C:\Users\eduru\Documents\Visual Studio 2022\Projects\popuploader\popuploader\MainPage.xaml.cs:line 18 at Microsoft.Maui.Controls.Button.Microsoft.Maui.Controls.Internals.IButtonElement.PropagateUpClicked() in D:\a_work\1\s\src\Controls\src\Core\Button\Button.cs:line 275 at Microsoft.Maui.Controls.ButtonElement.ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager) in D:\a_work\1\s\src\Controls\src\Core\Button\ButtonElement.cs:line 40 at Microsoft.Maui.Controls.Button.SendClicked() in D:\a_work\1\s\src\Controls\src\Core\Button\Button.cs:line 250 at Microsoft.Maui.Controls.Button.Microsoft.Maui.IButton.Clicked() in D:\a_work\1\s\src\Controls\src\Core\Button\Button.cs:line 484 at Microsoft.Maui.Handlers.ButtonHandler.OnClick(IButton button, View v) in D:\a_work\1\s\src\Core\src\Handlers\Button\ButtonHandler.Android.cs:line 148 at Microsoft.Maui.Handlers.ButtonHandler.ButtonClickListener.OnClick(View v) in D:\a_work\1\s\src\Core\src\Handlers\Button\ButtonHandler.Android.cs:line 169 at Android.Views.View.IOnClickListenerInvoker.n_OnClick_Landroid_view_View_(IntPtr jnienv, IntPtr native__this, IntPtr native_v) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.Views.View.cs:line 2374 at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 125}
@ekeneduru it would be best if you could file a new issue with detailed steps to reproduce.