Skip to content

Commit

Permalink
Potential fix for M.E.DI failure
Browse files Browse the repository at this point in the history
Fixes?

    [15:12:46.2484560] 2025-01-22 15:12:46.242709-0800 RunOniOSmauiRel1586373188[97228:54445246] Received unhandled Objective-C exception that was marshalled from a managed exception: A suitable constructor for type 'Microsoft.Maui.Hosting.FontsMauiAppBuilderExtensions+FontInitializer' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor. (System.InvalidOperationException)
[15:12:46.2484780]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache, ServiceIdentifier, Type, CallSiteChain) + 0x4de
[15:12:46.2485210]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor, ServiceIdentifier, CallSiteChain, Int32) + 0x1a5
[15:12:46.2485640]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateEnumerable(ServiceIdentifier, CallSiteChain) + 0x42f
[15:12:46.2485930]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain) + 0xfb
[15:12:46.2486100]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(ServiceIdentifier, CallSiteChain) + 0x92
[15:12:46.2486220]    at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier) + 0x68
[15:12:46.2486330]    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey, Func`2) + 0xdc
[15:12:46.2486790]    at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier, ServiceProviderEngineScope) + 0x39
[15:12:46.2486900]    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider, Type) + 0x3d
[15:12:46.2487000]    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider) + 0x2f
[15:12:46.2487100]    at Microsoft.Maui.MauiContextExtensions.InitializeAppServices(MauiApp) + 0x1b
[15:12:46.2487190]    at Microsoft.Maui.Hosting.MauiAppBuilder.Build() + 0x67
[15:12:46.2487420]    at Microsoft.Maui.MauiUIApplicationDelegate.WillFinishLaunching(UIApplication application, NSDictionary launchOptions) + 0x44
[15:12:46.2487530]    at RunOniOSmauiRel1586373188!<BaseAddress>+0xe200a
  • Loading branch information
jonathanpeppers committed Jan 23, 2025
1 parent 77c47dc commit 802e4c1
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Core/src/Hosting/Fonts/FontsMauiAppBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,23 @@ internal void AddFonts(IFontCollection fonts)

internal class FontInitializer : IMauiInitializeService
{
private readonly IEnumerable<FontsRegistration> _fontsRegistrations;
readonly FontsRegistration _fontsRegistration;
readonly IFontRegistrar _fontRegistrar;

public FontInitializer(IEnumerable<FontsRegistration> fontsRegistrations, IFontRegistrar fontRegistrar)
public FontInitializer(FontsRegistration fontsRegistration, IFontRegistrar fontRegistrar)
{
_fontsRegistrations = fontsRegistrations;
_fontsRegistration = fontsRegistration;
_fontRegistrar = fontRegistrar;
}

public void Initialize(IServiceProvider __)
{
if (_fontsRegistrations != null)
if (_fontsRegistration != null)
{
var fontsBuilder = new FontCollection();

// Run all the user-defined registrations
foreach (var font in _fontsRegistrations)
{
font.AddFonts(fontsBuilder);
}
_fontsRegistration.AddFonts(fontsBuilder);

// Register the fonts in the registrar
foreach (var font in fontsBuilder)
Expand Down

0 comments on commit 802e4c1

Please sign in to comment.