{"record":{"id":"cc41b50021712e92","repo":"dotnet/wpf","slug":"sr-nobackentry","errorCode":null,"errorMessage":"SR.NoBackEntry","messagePattern":"SR\\.NoBackEntry","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/JournalNavigationScope.cs","lineNumber":204,"sourceCode":"                JournalEntry je = Journal.BeginForwardNavigation();\n                // If je is null it indicates that we are going going \"forward\" to the currently\n                // displayed page which has no journal entry. The comment in BeginForwardNavigation\n                // explains how this can happen.\n                if (je == null)\n                {\n                    _rootNavSvc.StopLoading();\n                    return;\n                }\n                NavigateToEntry(je);\n                // NavigateToEntry() should call AbortJournalNavigation() if navigation is canceled.\n            }\n        }\n\n        public void GoBack()\n        {\n            // CanGoBack checks the calling thread and InAppShutdown as well\n            if (!CanGoBack)\n                throw new InvalidOperationException(SR.NoBackEntry);\n\n            if (!_host.GoBackOverride())\n            {\n                JournalEntry je = Journal.BeginBackNavigation();\n                if (je == null) // See comment in GoForwardInternal().\n                {\n                    _rootNavSvc.StopLoading();\n                    return;\n                }\n                NavigateToEntry(je);\n                // NavigateToEntry() should call Journal.AbortJournalNavigation() if navigation is canceled.\n            }\n        }\n\n        public void AddBackEntry(CustomContentState state)\n        {\n            _host.VerifyContextAndObjectState();\n            _rootNavSvc.AddBackEntry(state);","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/JournalNavigationScope.cs#L186-L222","documentation":"JournalNavigationScope.GoBack navigates backward in the WPF journal. It throws InvalidOperationException('no back entry') when CanGoBack is false — the back journal stack is empty, the call is made off the UI thread, or the application has shut down. There is no journal entry to go back to.","triggerScenarios":"Calling GoBack() when CanGoBack is false: first page shown (empty back stack), wrong thread, or after shutdown.","commonSituations":"Browser-chrome-like Back buttons enabled before any navigation occurred; calling GoBack right after navigation completes; calling from worker threads.","solutions":["Check CanGoBack before calling GoBack.","Initialize UI back-button state from CanGoBack and update it on navigation events (Navigated / CanGoBack changed).","Ensure the call executes on the UI thread via Dispatcher.Invoke.","Catch InvalidOperationException defensively when journal state can change concurrently."],"exampleFix":"// before\nbackButton.Click += (s, e) => journalScope.GoBack();\n// after\nbackButton.Click += (s, e) => { if (journalScope.CanGoBack) journalScope.GoBack(); };","handlingStrategy":"validation","validationCode":"if (journalScope.CanGoBack)\n    journalScope.GoBack();","typeGuard":null,"tryCatchPattern":"try\n{\n    journalScope.GoBack();\n}\ncatch (InvalidOperationException)\n{\n    // no back entry; disable back button\n}","preventionTips":["Initialize back-button state from CanGoBack at startup","Update IsEnabled on CanGoBack change notifications","Never call GoBack before first navigation completes","Marshal calls to the UI dispatcher"],"tags":["wpf","navigation","journal","invalid-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}