dotnet/wpf · error · InvalidOperationException

SR.NoForwardEntry

Error message

SR.NoForwardEntry

What it means

JournalNavigationScope.GoForward navigates forward in the WPF journal. It throws InvalidOperationException('no forward entry') when CanGoForward is false — the forward journal stack is empty, the call comes off the UI thread, or the application is already shut down. There is no journal entry to navigate to.

Solutions

  1. Check NavigationWindow/Frame.CanGoForward (or the scope's CanGoForward) before calling GoForward.
  2. Ensure navigation calls run on the UI Dispatcher thread.
  3. Subscribe to CanGoForward changed notifications to enable/disable UI navigation buttons instead of calling unconditionally.
  4. Wrap in try-catch for InvalidOperationException if state can race.

Example fix

// before
journalScope.GoForward();
// after
if (journalScope.CanGoForward)
    journalScope.GoForward();
Defensive patterns

Strategy: validation

Validate before calling

if (journalScope.CanGoForward)
    journalScope.GoForward();

Try / catch

try
{
    journalScope.GoForward();
}
catch (InvalidOperationException)
{
    // forward navigation unavailable; update UI state
}

Prevention

When it happens

Trigger: Calling GoForward() when CanGoForward is false: empty forward stack, calling from a non-UI thread, or after in-application shutdown.

Common situations: Custom navigation buttons wired to GoForward without checking CanGoForward; calling navigation methods after the window/frame closed; invoking from background threads.

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 dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/80f17138742da402. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/JournalNavigationScope.cs:182

            {
                _host.VerifyContextAndObjectState();
                return _journal != null && !InAppShutdown && _journal.CanGoForward;
            }
        }
        public bool CanGoBack
        {
            get
            {
                _host.VerifyContextAndObjectState();
                return _journal != null && !InAppShutdown && _journal.CanGoBack;
            }
        }

        public void GoForward()
        {
            // CanGoForward checks the calling thread and InAppShutdown as well
            if (!CanGoForward)
                throw new InvalidOperationException(SR.NoForwardEntry);

            if (!_host.GoForwardOverride())
            {
                JournalEntry je = Journal.BeginForwardNavigation();
                // If je is null it indicates that we are going going "forward" to the currently
                // displayed page which has no journal entry. The comment in BeginForwardNavigation
                // explains how this can happen.
                if (je == null)
                {
                    _rootNavSvc.StopLoading();
                    return;
                }
                NavigateToEntry(je);
                // NavigateToEntry() should call AbortJournalNavigation() if navigation is canceled.
            }
        }

        public void GoBack()

View on GitHub (pinned to 81131a70a4)