PrismLibrary/Prism · error · NavigationException

NavigationException.ErrorCreatingPage

NavigationException.ErrorCreatingPage

Error message

NavigationException.ErrorCreatingPage

What it means

This is the generic fallback in CreatePage: an exception occurred while instantiating the Page for a segment and it was not a NavigationException, KeyNotFoundException, ViewModelCreationException, or the dispatcher-thread case. Prism wraps it as NavigationException.ErrorCreatingPage with the segment name and original exception as InnerException.

Solutions

  1. Inspect the InnerException (the original ex) for the real cause and fix that
  2. Check the page's constructor and XAML for throwing code and missing resources/converters
  3. Register any services used in the page constructor so construction completes

Example fix

// before
public ViewBPage() { InitializeComponent(); LoadConfig(); // throws off main path
// after
public ViewBPage() { InitializeComponent(); }
protected override void OnNavigatedTo(INavigationParameters p) { SafeLoadConfig(); }
Defensive patterns

Strategy: try-catch

Try / catch

try { await _navigationService.NavigateAsync(segment); }
catch (NavigationException ne) when (ne.Message == NavigationException.ErrorCreatingPage)
{ Log(ne.InnerException); ShowFallbackPage(); }

Prevention

When it happens

Trigger: A Page's constructor or XAML load throws (missing resource/image, StaticResource key not found, x:Static failure, ctor exception); any non-registered exception type bubbling out of Registry.CreateView.

Common situations: XAML referencing a missing namespace, converter, or style; a page constructor throwing (file I/O, null config); version upgrades where a control no longer exists.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src/Maui/Prism.Maui/Navigation/PageNavigationService.cs:967

        catch(ViewModelCreationException vmce)
        {
            throw new NavigationException(NavigationException.ErrorCreatingViewModel, segmentName, _pageAccessor.Page, vmce);
        }
        //catch(ViewCreationException viewCreationException)
        //{
        //    if(!string.IsNullOrEmpty(viewCreationException.InnerException?.Message) && viewCreationException.InnerException.Message.Contains("Maui"))
        //        throw new NavigationException(NavigationException.)
        //}
        catch (Exception ex)
        {
            var inner = ex.InnerException;
            while(inner is not null)
            {
                if (inner.Message.Contains("thread with a dispatcher"))
                    throw new NavigationException(NavigationException.UnsupportedMauiCreation, segmentName, _pageAccessor.Page, ex);
                inner = inner.InnerException;
            }
            throw new NavigationException(NavigationException.ErrorCreatingPage, segmentName, ex);
        }
    }

    protected virtual Page CreatePageFromSegment(string segment)
    {
        string segmentName = UriParsingHelper.GetSegmentName(segment);
        var page = CreatePage(segmentName);
        if (page is null)
        {
            var innerException = new NullReferenceException(string.Format("{0} could not be created. Please make sure you have registered {0} for navigation.", segmentName));
            throw new NavigationException(NavigationException.NoPageIsRegistered, segmentName, _pageAccessor.Page, innerException);
        }

        return page;
    }

    async Task ConfigureTabbedPage(TabbedPage tabbedPage, string segment, INavigationParameters parameters)
    {

View on GitHub (pinned to 358118cd64)