.NET MAUI › Fundamentals & Architecture
Explain the MAUI app startup and the role of MauiProgram.
AdvancedAnswer
MAUI uses the .NET Generic Host. MauiProgram.CreateMauiApp() builds a MauiAppBuilder where you register the App class via UseMauiApp<App>(), configure fonts, register services in the DI container, and add handlers or libraries. The builder produces a MauiApp that the platform-specific entry points (MainActivity, AppDelegate) bootstrap.
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"));
builder.Services.AddSingleton<IDataService, DataService>();
builder.Services.AddTransient<MainPage>();
return builder.Build();
}Real-world example A team wires up logging, HTTP clients, and view models in MauiProgram so every page resolves its dependencies from the host container.