{"record":{"id":"0c912340ee21d148","repo":"PrismLibrary/Prism","slug":"prism-applications-only-support-the-use-of-prismwindow-but","errorCode":null,"errorMessage":"Prism applications only support the use of PrismWindow, but found '{window.GetType().FullName}'.","messagePattern":"Prism applications only support the use of PrismWindow, but found '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs","lineNumber":40,"sourceCode":"    /// <summary>\n    /// Gets the <see cref=\"IDialogService\"/> for the currently displayed <see cref=\"Page\"/>.\n    /// </summary>\n    /// <param name=\"windowManager\">The <see cref=\"IWindowManager\"/>.</param>\n    /// <returns>The <see cref=\"IDialogService\"/> for the current <see cref=\"Page\"/>.</returns>\n    public static IDialogService GetCurrentDialogService(this IWindowManager windowManager)\n    {\n        var page = windowManager.GetCurrentPage();\n        var container = page.GetContainerProvider();\n        return container.Resolve<IDialogService>();\n    }\n\n    private static Page GetCurrentPage(this IWindowManager windowManager)\n    {\n        var window = windowManager.Current;\n        if (window is null)\n            throw new InvalidOperationException(\"No Window has been set in the Application\");\n        else if (window is not PrismWindow prismWindow)\n            throw new InvalidOperationException($\"Prism applications only support the use of PrismWindow, but found '{window.GetType().FullName}'.\");\n        else if (prismWindow.CurrentPage is null)\n            throw new InvalidOperationException(\"No current page has been set.\");\n        else\n            return prismWindow.CurrentPage;\n    }\n}\n","sourceCodeStart":22,"sourceCodeEnd":47,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs#L22-L47","documentation":"Prism.Maui requires the application's active window to be a PrismWindow (its own Window subclass carrying CurrentPage state). GetCurrentPage throws InvalidOperationException with the concrete offending type name when windowManager.Current is any other Window - typically a plain Microsoft.Maui.Controls.Window created by the default MAUI template.","triggerScenarios":"Overriding CreateWindow to `return new Window(page);` instead of PrismWindow; using MAUI Shell (Shell windows) with Prism's WindowManager extensions; another library swapping the application's main Window.","commonSituations":"New MAUI projects created from the default template then adding Prism, without removing the default `new Window(this)` in MauiProgram/App; mixing Shell and Prism navigation.","solutions":["Change CreateWindow to return a PrismWindow: `protected override Window CreateWindow(IActivationState state) => new PrismWindow(...);`","Let Prism create the window automatically (remove custom CreateWindow override) and configure the app via PrismAppBuilder.","If Shell is required, don't use Prism's IWindowManager page extensions, which assume PrismWindow."],"exampleFix":"// before\nprotected override Window CreateWindow(IActivationState s) => new Window(startupPage);\n// after\nprotected override Window CreateWindow(IActivationState s) => new PrismWindow(startupPage);","handlingStrategy":"validation","validationCode":"if (Application.Current?.Windows.Any(w => w is not PrismWindow) ?? false)\n    throw new InvalidOperationException(\"All windows must be PrismWindow for Prism.Maui\");","typeGuard":"bool IsPrismHosted(IWindowManager wm) => wm.Current is PrismWindow;","tryCatchPattern":"try { var page = windowManager.GetCurrentPage(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"PrismWindow\"))\n{\n    // fix CreateWindow to return a PrismWindow\n}","preventionTips":["Never return plain Window from CreateWindow in a Prism.Maui app","Don't mix MAUI Shell window management with Prism WindowManager","After Prism upgrades, re-check that window creation still uses PrismWindow"],"tags":["prism","maui","prismwindow","window","type-mismatch"],"backgroundTag":"type-mismatch","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"}