dotnet/maui · error · InvalidOperationException
Unexpected navigation type
Error message
Unexpected navigation type
What it means
Thrown by the Android ShellItemRendererBase in its navigation handling switch statement. The switch covers known ShellNavigationSource values (Insert, Remove, Push, Pop, PopToRoot, ShellSectionChanged) and the default case throws InvalidOperationException for any unrecognized navigation source. This means a navigation request was initiated with a ShellNavigationSource value the renderer does not know how to process, which typically indicates a framework version mismatch or a custom/extension navigation source.
Source
Thrown at src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRendererBase.cs:195
if (!isForCurrentTab && removeFragment != _currentFragment)
return Task.FromResult(true);
break;
case ShellNavigationSource.PopToRoot:
RemoveAllPushedPages(shellSection, isForCurrentTab);
if (!isForCurrentTab)
return Task.FromResult(true);
break;
case ShellNavigationSource.ShellSectionChanged:
// We need to handle this after we know what the target is
// because we might accidentally remove an already added target.
// Then there would be two transactions in a row, one removing and one adding
// the same fragment and things get really screwy when you do that.
break;
default:
throw new InvalidOperationException("Unexpected navigation type");
}
IReadOnlyList<Page> stack = ShellSection.Stack;
Element targetElement = null;
IShellObservableFragment target = null;
if (stack.Count == 1 || navSource == ShellNavigationSource.PopToRoot)
{
target = _fragmentMap[ShellSection];
targetElement = ShellSection;
}
else
{
targetElement = stack[stack.Count - 1];
if (!_fragmentMap.ContainsKey(targetElement))
_fragmentMap[targetElement] = CreateFragmentForPage(targetElement as Page);
target = _fragmentMap[targetElement];
}
View on GitHub (pinned to f377ff1c5e)
Solutions
- If using a pre-release MAUI build, update to a stable release or a newer build that has matching renderer support for all ShellNavigationSource values.
- Check that no custom Shell subclass or third-party library is injecting non-standard ShellNavigationSource values into navigation requests.
- File a bug report with the MAUI team including the exact ShellNavigationSource value that triggered the default case (add logging before the switch to capture navSource.ToString()).
- Ensure MAUI NuGet packages are all at the same version across the solution to avoid enum definition mismatches.
Defensive patterns
Strategy: try-catch
Validate before calling
// Log navigation source for debugging var navSource = (e.Request as ShellNavigationRequest)?.Source; // Known sources: Insert, Remove, Push, Pop, PopToRoot, ShellSectionChanged
Try / catch
try { await Shell.Current.GoToAsync(route); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Unexpected navigation type"))
{
// Framework/navigation source mismatch — log and report
// Likely a version mismatch between MAUI packages Prevention
- Keep all MAUI NuGet packages at the same version across the solution.
- Avoid custom Shell subclasses that inject non-standard navigation sources.
- Use stable MAUI releases in production.
When it happens
Trigger: At the `default:` case of the switch on `navSource` (ShellNavigationSource). Triggered when ShellSection.OnNavigateAsync or equivalent passes a ShellNavigationSource enum value not covered by the switch cases. This could be a future enum value, a custom enum value injected via reflection or a custom Shell implementation, or an internal navigation path that was added to the enum but not to this renderer's switch.
Common situations: 1) Using a pre-release or nightly MAUI build where a new ShellNavigationSource was added to the enum but renderer handling wasn't updated. 2) Custom Shell subclass that injects non-standard navigation requests. 3) Version mismatch between the MAUI NuGet package and a compatibility/extension library that uses different navigation sources. 4) Extremely rare — a framework regression where an internal navigation path uses an uncovered source.
Related errors
- Active Shell Item not set. Have you added any Shell Items to
- Content not found for active {ShellItem}. Title: {ShellItem.
- LoadView must be called before accessing View
- Shell Content Page is Null
- Content not found for active {shellSection}. Title: {shellSe
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/603890419bbde35c.
Report an issue: GitHub.