{"record":{"id":"5cc762b34c18e599","repo":"dotnet/wpf","slug":"sr-invalidoperation-nojournal","errorCode":null,"errorMessage":"SR.InvalidOperation_NoJournal","messagePattern":"SR\\.InvalidOperation_NoJournal","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Frame.cs","lineNumber":846,"sourceCode":"        /// </summary>\n        /// <param name=\"state\"> The custom content state (or view state) to be encapsulated in the\n        /// journal entry. If null, IProvideCustomContentState.GetContentState() will be called on\n        /// the NavigationWindow.Content or Frame.Content object.\n        /// </param>\n        public void AddBackEntry(CustomContentState state)\n        {\n            VerifyAccess();\n            _navigationService.AddBackEntry(state);\n        }\n\n        /// <summary>\n        /// Removes the first JournalEntry from the frame's back stack.\n        /// </summary>\n        /// <exception cref=\"InvalidOperationException\"> The frame doesn't own a journal. </exception>\n        public JournalEntry RemoveBackEntry()\n        {\n            if (_ownJournalScope == null)\n                throw new InvalidOperationException(SR.InvalidOperation_NoJournal);\n            return _ownJournalScope.RemoveBackEntry();\n        }\n\n        /// <summary>\n        /// Navigates to the Uri and downloads the content. Whether the navigation is\n        /// performed synchronously or asynchronously depends on the current default navigation behavior.\n        /// </summary>\n        /// <param name=\"source\">URI of the application or content being navigated to.</param>\n        /// <returns>bool indicating whether the navigation was successfully started or not</returns>\n        public bool Navigate(Uri source)\n        {\n            VerifyAccess();\n            return _navigationService.Navigate(source);\n        }\n\n        //\n        //  INavigator.Navigate\n        //","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Frame.cs#L828-L864","documentation":"Frame.RemoveBackEntry() throws InvalidOperationException when the frame does not own its own journal (_ownJournalScope == null). A Frame only maintains a back/forward stack when it owns a journal (JournalOwnership set to OwnsJournal, or the frame is a top-level navigation host). When the journal is owned by a parent Frame/NavigationWindow or disabled, journal operations on the child frame are unsupported and the library fails fast.","triggerScenarios":"Calling Frame.RemoveBackEntry() on a frame whose _ownJournalScope is null — i.e. the frame uses Automatic journal ownership and resolved to a parent's journal, or JournalOwnership is set to UsesParentJournal, or navigation/journaling is disabled.","commonSituations":"Embedding a Frame inside a NavigationWindow or another Frame and trying to prune the child's back stack; setting JournalOwnership=UsesParentJournal then calling journal APIs on the child; calling RemoveBackEntry before the frame has ever navigated with its own journal.","solutions":["Set Frame.JournalOwnership = JournalOwnership.OwnsJournal on the frame so it owns its journal before calling RemoveBackEntry().","Call RemoveBackEntry on the object that actually owns the journal (the parent Frame or NavigationWindow) instead of the child frame.","Check Frame.CanGoBack (or _ownJournalScope via CanGoBack) and JournalOwnership before calling journal APIs."],"exampleFix":"// before\nframe.RemoveBackEntry(); // throws: frame uses parent's journal\n// after\nif (frame.JournalOwnership != JournalOwnership.OwnsJournal)\n{\n    frame.JournalOwnership = JournalOwnership.OwnsJournal;\n}\nif (frame.CanGoBack)\n{\n    frame.RemoveBackEntry();\n}","handlingStrategy":"try-catch","validationCode":"bool safe = frame.JournalOwnership == JournalOwnership.OwnsJournal && frame.CanGoBack;","typeGuard":"bool CanRemoveBackEntry(Frame f) => f.JournalOwnership == JournalOwnership.OwnsJournal && f.CanGoBack;","tryCatchPattern":"try { frame.RemoveBackEntry(); }\ncatch (InvalidOperationException) { /* journal owned by parent; delegate to owner or ignore */ }","preventionTips":["Set JournalOwnership=OwnsJournal when a frame should manage its own back stack","Check CanGoBack before journal operations","Perform journal mutations on the journal-owning container"],"tags":["wpf","frame","journal","navigation","invalid-operation"],"backgroundTag":"unsupported-operation","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"}