{"record":{"id":"00fae75d0a0e6e4c","repo":"PrismLibrary/Prism","slug":"the-current-window-windowmanager-current-gettype-fullname-is","errorCode":null,"errorMessage":"The current window '{_windowManager.Current.GetType().FullName}' is not a PrismWindow.","messagePattern":"The current window '(.+?)' is not a PrismWindow\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Dialogs/SingletonDialogService.cs","lineNumber":35,"sourceCode":"    private readonly IWindowManager _windowManager;\n\n    /// <summary>\n    /// Initializes a new SingletonDialogService\n    /// </summary>\n    /// <param name=\"windowManager\">An instance of the <see cref=\"IWindowManager\"/>.</param>\n    public SingletonDialogService(IWindowManager windowManager)\n    {\n        ArgumentNullException.ThrowIfNull(windowManager);\n        _windowManager = windowManager;\n    }\n\n    /// <inheritdoc/>\n    protected override Page? GetCurrentPage()\n    {\n        if (_windowManager.Current is null)\n            throw new NotSupportedException(\"There is currently no application window.\");\n        else if (_windowManager.Current is not PrismWindow prismWindow)\n            throw new NotSupportedException($\"The current window '{_windowManager.Current.GetType().FullName}' is not a PrismWindow.\");\n        else\n            return prismWindow.CurrentPage;\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":40,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Dialogs/SingletonDialogService.cs#L17-L40","documentation":"SingletonDialogService requires the current window to be a PrismWindow, because PrismWindow tracks CurrentPage for dialog placement. If IWindowManager.Current is some other Window subclass (a plain Microsoft.Maui.Controls.Window or custom window), Prism throws NotSupportedException naming the actual type.","triggerScenarios":"Creating the app's Window as `new Window(mainPage)` or a custom Window subclass instead of PrismWindow — e.g. overriding CreateWindow in App to return a non-Prism window, then calling dialog APIs.","commonSituations":"Customizing window creation in App.CreateWindow for multi-window or splash scenarios and losing PrismWindow; upgrading Prism.Maui and replacing the default window factory; mixing plain MAUI window management with Prism dialogs.","solutions":["Let Prism create the window (remove the CreateWindow override) so a PrismWindow is used.","If you must create the window, make your custom window derive from PrismWindow.","Ensure startup uses PrismAppBuilder (UsePrismAppNaming / PrismApplication) rather than raw MauiApplication window setup."],"exampleFix":"// before\nprotected override Window CreateWindow(IActivationState state)\n    => new Window(new MainPage());\n// after\nprotected override Window CreateWindow(IActivationState state)\n    => new PrismWindow(new MainPage()); // or delete the override entirely","handlingStrategy":"type-guard","validationCode":"var window = Application.Current?.Windows?.FirstOrDefault();\nif (window is not PrismWindow)\n    throw new InvalidOperationException(\"App window must be a PrismWindow for dialogs\");","typeGuard":"bool IsPrismWindow(IWindow w) => w is PrismWindow;","tryCatchPattern":"try { await dialogService.ShowDialogAsync(name); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"PrismWindow\"))\n{ logger.Error(ex, \"Current window is not a PrismWindow\"); }","preventionTips":["Do not override CreateWindow to return a plain Window; let Prism create PrismWindow.","If overriding is required, derive your window from PrismWindow.","Add a startup assertion that Application.Current.Windows[0] is PrismWindow."],"tags":["prism","maui","dialogs","window","prismwindow"],"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"}