PrismLibrary/Prism · error · NotSupportedException

There is currently no application window.

Error message

There is currently no application window.

What it means

SingletonDialogService.GetCurrentPage needs the app's current window to find the page hosting a dialog. If IWindowManager.Current is null — no window exists yet or all windows were closed — it throws NotSupportedException "There is currently no application window.". Dialogs cannot be shown or closed without an active window.

Solutions

  1. Defer dialog calls until a window exists (e.g. wait for the first Page's OnAppearing or the Window created event).
  2. Check IWindowManager.Current (or Application.Windows) for null before requesting dialogs.
  3. Route background-triggered dialogs through a queue that shows them once the window is ready.
  4. Catch NotSupportedException and fall back to a non-UI notification.

Example fix

// before
OnInitialized(); // ShowDialog called immediately
// after
protected override void OnWindowCreated(Window window)
{
    base.OnWindowCreated(window);
    ShowPendingDialog(); // window now exists
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (Application.Current?.Windows?.Any() != true)
    return; // no window yet — defer the dialog

Type guard

bool HasWindow(IWindowManager wm) => wm.Current is not null;

Try / catch

try { await dialogService.ShowDialogAsync(name); }
catch (NotSupportedException ex) when (ex.Message.Contains("no application window"))
{ QueueDialogUntilWindowReady(name); }

Prevention

When it happens

Trigger: Calling ShowDialog/CloseDialogAsync before the MAUI window is created (e.g. in OnStart before window assignment, in a constructor run at app init) or after the last window was closed; a background service attempting to open a dialog with no UI window.

Common situations: Showing a dialog from App constructor / startup code; unit-test or design-time environments without a window; calling dialogs from a headless/background path (push-notification handler) when the app was relaunched without UI.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at src/Maui/Prism.Maui/Dialogs/SingletonDialogService.cs:33

public sealed class SingletonDialogService : DialogServiceBase
{
    private readonly IWindowManager _windowManager;

    /// <summary>
    /// Initializes a new SingletonDialogService
    /// </summary>
    /// <param name="windowManager">An instance of the <see cref="IWindowManager"/>.</param>
    public SingletonDialogService(IWindowManager windowManager)
    {
        ArgumentNullException.ThrowIfNull(windowManager);
        _windowManager = windowManager;
    }

    /// <inheritdoc/>
    protected override Page? GetCurrentPage()
    {
        if (_windowManager.Current is null)
            throw new NotSupportedException("There is currently no application window.");
        else if (_windowManager.Current is not PrismWindow prismWindow)
            throw new NotSupportedException($"The current window '{_windowManager.Current.GetType().FullName}' is not a PrismWindow.");
        else
            return prismWindow.CurrentPage;
    }
}

View on GitHub (pinned to 358118cd64)