dotnet/maui · error · InvalidOperationException
RemovePage is not supported globally on Windows, please use
Error message
RemovePage is not supported globally on Windows, please use a LightNavigationPage.
What it means
IFormsNavigation.RemovePage throws InvalidOperationException stating RemovePage is not supported globally on Windows and instructs to use a LightNavigationPage. The FormsWindow navigation proxy rejects page removal; only a LightNavigationPage supports stack mutation.
Source
Thrown at src/Compatibility/Core/src/WPF/Interfaces/IFormsNavigation.cs:106
public void Push(object page, bool animated)
{
throw new InvalidOperationException("Push is not supported globally on Windows, please use a LightNavigationPage.");
}
public void PushModal(object page)
{
PushModal(page, true);
}
public void PushModal(object page, bool animated)
{
ParentWindow?.PushModal(page, animated);
}
public void RemovePage(object page)
{
throw new InvalidOperationException(
"RemovePage is not supported globally on Windows, please use a LightNavigationPage.");
}
public int StackDepth =>
throw new InvalidOperationException(
"StackDepth is not supported globally on Windows, please use a LightNavigationPage.");
}
}View on GitHub (pinned to f377ff1c5e)
Solutions
- Use a LightNavigationPage and call RemovePage on that instance.
- Branch by platform: only remove pages when Navigation is a per-page NavigationPage.
- Ensure NavigationProxy resolves to the page-level NavigationPage.
- Provide a WPF-specific INavigation implementation if removal is required.
Example fix
// before
Navigation.RemovePage(oldPage);
// after
if (Navigation is LightNavigationPage lnp)
lnp.RemovePage(oldPage); Defensive patterns
Strategy: type-guard
Validate before calling
if (Navigation is LightNavigationPage lnp) lnp.RemovePage(page);
else throw new PlatformNotSupportedException("Use LightNavigationPage on WPF."); Type guard
static bool CanRemove(NavigationProxy n) => n is LightNavigationPage;
Try / catch
try { Navigation.RemovePage(page); }
catch (InvalidOperationException ex) when (ex.Message.Contains("LightNavigationPage"))
{ /* wrap in LightNavigationPage, retry */ } Prevention
- Use LightNavigationPage when stack mutation is needed on WPF.
- Branch remove logic by Navigation type.
- Audit NavigationProxy routing.
When it happens
Trigger: Calling Navigation.RemovePage(page) against the window-level navigation proxy; removing pages from the global stack instead of a per-page NavigationPage.
Common situations: Cross-platform code removing pages from the back stack; pages not wrapped in a LightNavigationPage.
Related errors
- InsertPageBefore is not supported globally on Windows, pleas
- Pop is not supported globally on Windows, please use a Light
- PopToRoot is not supported globally on Windows, please use a
- Push is not supported globally on Windows, please use a Ligh
- StackDepth is not supported globally on Windows, please use
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/9b0a9c5ac87d64c2.
Report an issue: GitHub.