{"record":{"id":"cbf67f69e5c07cdb","repo":"dotnet/wpf","slug":"sr-hyperlinktargetnotfound","errorCode":null,"errorMessage":"SR.HyperLinkTargetNotFound","messagePattern":"SR\\.HyperLinkTargetNotFound","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs","lineNumber":205,"sourceCode":"            {\n                if (inSameThread)\n                {\n                    navigator.Navigate(bpu);\n                }\n                else\n                {\n                    ((DispatcherObject)navigator).Dispatcher.BeginInvoke(\n                                DispatcherPriority.Send,\n                                (DispatcherOperationCallback)delegate(object unused)\n                                {\n                                    return navigator.Navigate(bpu);\n                                },\n                                null);\n                }\n            }\n            else\n            {\n                throw new System.ArgumentException(SR.HyperLinkTargetNotFound);\n            }\n        }\n\n        // Tests if two uris resolve to the same Uri.  The Uri fragments are also\n        // compared.  Neither comparison is case sensitive.\n        private static bool IsSameUri(Uri baseUri, Uri a, Uri b, bool withFragment)\n        {\n            if (object.ReferenceEquals(a, b)) // also handles both null\n            {\n                return true;\n            }\n            if (a == null || b == null)\n            {\n                return false;\n            }\n\n            Uri aResolved = BindUriHelper.GetResolvedUri(baseUri, a);\n            Uri bResolved = BindUriHelper.GetResolvedUri(baseUri, b);","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs#L187-L223","documentation":"NavigationService.OnRequestNavigate() handles a Hyperlink click; when the hyperlink's target (NavigateUri) cannot be resolved — the handler does not produce a navigation target — it throws ArgumentException with HyperLinkTargetNotFound. It signals that the URI the hyperlink points at has no resolvable destination at that point.","triggerScenarios":"Clicking a Hyperlink whose NavigateUri is null/empty or whose target (e.g. relative pack URI or named element/fragment) cannot be resolved by the hosting NavigationService in OnRequestNavigate.","commonSituations":"Relative pack URIs in a page hosted without a proper Application/Frame context; typos in NavigateUri; hyperlinks placed in surfaces (e.g. certain popups/controls) without navigation container; missing base URI for relative resolution.","solutions":["Use an absolute pack URI, e.g. pack://application:,,,/MyPage.xaml, instead of an ambiguous relative URI","Ensure the hyperlink is hosted in a Frame or NavigationWindow that can resolve the target","Verify the NavigateUri and TargetName spellings and that the target resource exists in the assembly","Handle NavigationService.NavigationFailed to catch resolution problems gracefully"],"exampleFix":"<!-- before -->\n<TextBlock><Hyperlink NavigateUri=\"Page2.xaml\">Go</Hyperlink></TextBlock>\n<!-- after -->\n<TextBlock><Hyperlink NavigateUri=\"pack://application:,,,/MyApp;component/Page2.xaml\">Go</Hyperlink></TextBlock>","handlingStrategy":"validation","validationCode":"bool resolvable = hyperlink.NavigateUri != null && hyperlink.NavigateUri.IsAbsoluteUri;\nif (!resolvable) hyperlink.NavigateUri = new Uri(\"pack://application:,,,/TargetPage.xaml\", UriKind.Absolute);","typeGuard":"bool HasResolvableTarget(Hyperlink h) =>\n    h?.NavigateUri != null && h.NavigateUri.ToString().StartsWith(\"pack://\");","tryCatchPattern":"try { frame.NavigationService.Navigate(hyperlink.NavigateUri); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"target\")) {\n    // fall back to default page or show message\n}","preventionTips":["Use absolute pack URIs for NavigateUri","Host hyperlinks inside Frame/NavigationWindow","Subscribe to NavigationFailed to log unresolved URIs early"],"tags":["wpf","navigation","hyperlink","uri-resolution"],"backgroundTag":"invalid-url","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"}