dotnet/maui · error · InvalidOperationException
RemovePage is not supported globally on macOS, please use a
Error message
RemovePage is not supported globally on macOS, please use a NavigationPage.
What it means
RemovePage (removing a page from the middle of a stack) is a stack-level operation; the macOS global Platform has no page stack, so PlatformNavigation throws InvalidOperationException. Removal must go through a NavigationPage that owns the stack being edited.
Source
Thrown at src/Compatibility/Core/src/MacOS/PlatformNavigation.cs:85
Task<Page> INavigation.PopModalAsync()
{
return ((INavigation)this).PopModalAsync(true);
}
Task INavigation.PushModalAsync(Page modal, bool animated)
{
return _modalTracker.PushAsync(modal, _animateModals && animated);
}
Task<Page> INavigation.PopModalAsync(bool animated)
{
return _modalTracker.PopAsync(animated);
}
void INavigation.RemovePage(Page page)
{
throw new InvalidOperationException("RemovePage is not supported globally on macOS, please use a NavigationPage.");
}
void INavigation.InsertPageBefore(Page page, Page before)
{
throw new InvalidOperationException(
"InsertPageBefore is not supported globally on macOS, please use a NavigationPage.");
}
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
_modalTracker.Dispose();
_modalTracker = null;
_platformRenderer = null;
}View on GitHub (pinned to f377ff1c5e)
Solutions
- Host pages in a NavigationPage (MainPage = new NavigationPage(root)) and call RemovePage on a page within it.
- Re-architect the flow to use modal push/pop if a NavigationPage isn't suitable on macOS.
- Guard RemovePage so it only runs when a NavigationPage ancestor is present.
Example fix
// before MainPage = new ContentPage(); Navigation.RemovePage(loginPage); // throws on macOS // after MainPage = new NavigationPage(loginPage); await Navigation.PushAsync(home); Navigation.RemovePage(loginPage);
Defensive patterns
Strategy: validation
Validate before calling
if (page.Parent is NavigationPage np && np.Navigation.NavigationStack.Contains(target))
Navigation.RemovePage(target); Type guard
static bool CanRemovePage(Page target) => target?.Parent is NavigationPage;
Prevention
- Only RemovePage against a NavigationPage-owned stack.
- Confirm the target is on the stack before removing.
- Keep wizard/login flows inside a NavigationPage.
When it happens
Trigger: Calling Navigation.RemovePage(page) when Navigation points at the global macOS Platform — MainPage is not a NavigationPage, so there is no stack to remove from.
Common situations: Login/wizard flows that remove intermediate pages via Navigation.RemovePage. Shared navigation utilities assuming a global stack. Logout cleanup code.
Related errors
- PopAsync is not supported globally on macOS, please use a Na
- PopToRootAsync is not supported globally on macOS, please us
- PushAsync is not supported globally on macOS, please use a N
- InsertPageBefore is not supported globally on macOS, please
- PopToRootAsync is not supported globally on GTK, please use
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/cba65f1bc6fcf42d.
Report an issue: GitHub.