{"record":{"id":"22161d5e78cb3951","repo":"PrismLibrary/Prism","slug":"expected-navigation-failed-no-root-window-has-been-created","errorCode":null,"errorMessage":"Expected Navigation Failed. No Root Window has been created.","messagePattern":"Expected Navigation Failed\\. No Root Window has been created\\.","errorType":"exception","errorClass":"InvalidNavigationException","httpStatus":null,"severity":"critical","filePath":"src/Maui/Prism.Maui/Navigation/PrismWindowManager.cs","lineNumber":31,"sourceCode":"    }\n\n    private Window _initialWindow;\n\n    private Window _current;\n    public Window Current => _current ?? _initialWindow;\n\n    public IReadOnlyList<Window> Windows => _application.Windows.OfType<Window>().ToList();\n\n    public Window CreateWindow(Application app, IActivationState activationState)\n    {\n        if (_initialWindow is not null)\n            return _initialWindow;\n        else if (app.Windows.OfType<PrismWindow>().Any())\n            return _initialWindow = app.Windows.OfType<PrismWindow>().First();\n\n        activationState.Context.Services.GetRequiredService<PrismAppBuilder>().OnCreateWindow();\n\n        return _initialWindow ?? throw new InvalidNavigationException(\"Expected Navigation Failed. No Root Window has been created.\");\n    }\n\n    public void OpenWindow(Window window)\n    {\n        if (_initialWindow is null)\n            _initialWindow = window;\n        else\n            _application.OpenWindow(window);\n\n        foreach(var pWindow in Windows.OfType<PrismWindow>().Where(x => x.IsActive))\n        {\n            pWindow.IsActive = window.Equals(pWindow);\n        }\n    }\n\n    public void CloseWindow(Window window)\n    {\n        if (_initialWindow == window)","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/PrismWindowManager.cs#L13-L49","documentation":"PrismWindowManager.CreateWindow is responsible for producing the app's initial PrismWindow. It first checks the app's Windows collection, then triggers PrismAppBuilder.OnCreateWindow() and, if still no window was created, throws InvalidNavigationException 'Expected Navigation Failed. No Root Window has been created.' This means the Prism window-creation pipeline never registered a root window, so no navigation can be started.","triggerScenarios":"MAUI's built-in Window creation bypasses Prism - e.g. not removing the default 'CreateWindow' handling or not letting Prism's CreateWindow handler run; a custom IWindowCreator/App.Start returning null; App.xaml.cs overrides CreateWindow and does not call the Prism path; PrismAppBuilder.OnCreateWindow produced no window due to missing view registration for the initial navigation.","commonSituations":"Upgrading a MAUI app where the default App.CreateWindow override from the template still exists and intercepts window creation; forgetting to call builder.UsePrismAppBuilder or removing OnAppStart navigation; custom splash/window logic creating a non-PrismWindow.","solutions":["Remove any custom CreateWindow override in App (or the default template one) so Prism's window manager handles window creation.","Ensure PrismAppBuilder is configured with UsePrismAppBuilder and that OnAppStart sets a valid initial navigation URI whose view is registered.","If a custom IWindowCreator is used, verify it actually creates/returns a PrismWindow.","Check that the initial route/view named in OnAppStart is registered via RegisterForNavigation; a failed initial nav can leave _initialWindow null."],"exampleFix":"// before (App.xaml.cs)\nprotected override Window CreateWindow(IActivationState activationState) =>\n    new Window(); // bypasses Prism\n\n// after\n// delete the override and configure Prism:\nbuilder.UsePrismAppBuilder(prism => prism.OnAppStart(navigation =>\n    navigation.CreateBuilder().NavigateAsync(\"MainPage\")));","handlingStrategy":"validation","validationCode":"// verify prism window creation at startup\nvar window = App.Current.Windows.OfType<PrismWindow>().FirstOrDefault();\nif (window is null)\n    throw new InvalidOperationException(\"Prism window not created; check OnAppStart and App.CreateWindow override.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never override App.CreateWindow in a Prism MAUI app.","Confirm OnAppStart registers a valid, registered initial view.","Call builder.UsePrismAppBuilder in MauiProgram.","Test cold start on each platform after upgrades."],"tags":["maui","window","startup","prism"],"backgroundTag":"missing-dependency","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}