PrismLibrary/Prism · critical · ArgumentException

You must call CreateWindow on the PrismAppBuilder.

Error message

You must call CreateWindow on the PrismAppBuilder.

What it means

PrismAppBuilder.OnCreateWindow requires that a CreateWindow delegate was configured on the builder. If none was supplied, it throws this ArgumentException because Prism cannot determine which page to show when the MAUI platform asks for the app's first window.

Solutions

  1. Add .CreateWindow(container => container.Resolve<INavigationService>().NavigateAsync("/ MainPage")) (or equivalent) to your PrismAppBuilder chain in MauiProgram.CreateMauiApp.
  2. Ensure you call CreateWindow on the builder returned by UsePrism, not somewhere unreachable.
  3. Verify the navigation path passed to CreateWindow resolves to a registered page.

Example fix

// before
builder.UsePrism(prism => prism.RegisterTypes(r => r.ForNavigation<MainPage>()));
// after
builder.UsePrism(prism => prism
    .RegisterTypes(r => r.ForNavigation<MainPage>())
    .CreateWindow(nav => nav.CreateBuilder()
        .AddSegment("MainPage")
        .NavigateAsync()));
Defensive patterns

Strategy: validation

Validate before calling

// In MauiProgram, before building the app
var prism = builder.UsePrism(prism => ...);
// ensure CreateWindow was chained
if (!typeof(PrismAppBuilder).GetField("_createWindow", BindingFlags.NonPublic | BindingFlags.Instance)!
       .GetValue(prism)!.Equals(null))
    throw new InvalidOperationException("CreateWindow not configured");

Prevention

When it happens

Trigger: Using UsePrism without chaining .CreateWindow(navigation => ...) (or CreateWindow returning null delegate) so _createWindow is null when MAUI creates the app window.

Common situations: New project setup missing the CreateWindow call; copying an App builder from a template that sets the window elsewhere; accidentally deleting the CreateWindow line during refactoring.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15). Data as JSON: /api/errors/227d9c5eba5cef77. Report an issue: GitHub.

Appendix: source

Thrown at src/Maui/Prism.Maui/PrismAppBuilder.cs:283

                .RegisterInstance(new ViewRegistration
                {
                    Name = nameof(NavigationPage),
                    View = typeof(PrismNavigationPage),
                    Type = ViewType.Page
                });
        }

        if (!navRegistry.IsRegistered(nameof(TabbedPage)))
        {
            var registry = _container as IContainerRegistry;
            registry.RegisterForNavigation<TabbedPage>();
        }
    }

    internal void OnCreateWindow()
    {
        if (_createWindow is null)
            throw new ArgumentException("You must call CreateWindow on the PrismAppBuilder.");

        // Ensure that this is executed before we navigate.
        OnInitialized();
        var onStart = _createWindow(_container, _container.Resolve<INavigationService>());
        onStart.Wait();
    }

    /// <summary>
    /// When the <see cref="Application"/> is started and the native platform calls <see cref="IApplication.CreateWindow(IActivationState?)"/>
    /// this delegate will be invoked to do your initial Navigation.
    /// </summary>
    /// <param name="createWindow">The Navigation Delegate.</param>
    /// <returns>The <see cref="PrismAppBuilder"/>.</returns>
    public PrismAppBuilder CreateWindow(Func<IContainerProvider, INavigationService, Task> createWindow)
    {
        _createWindow = createWindow;
        return this;
    }

View on GitHub (pinned to 358118cd64)