{"record":{"id":"408d82398e33b663","repo":"PrismLibrary/Prism","slug":"argumentnullexception-nameof-navigation","errorCode":null,"errorMessage":"ArgumentNullException(nameof(navigation))","messagePattern":"ArgumentNullException\\(nameof\\(navigation\\)\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Prism.Core/Navigation/Regions/NavigationAsyncExtensions.cs","lineNumber":43,"sourceCode":"        /// Initiates navigation to the target specified by the <paramref name=\"target\"/>.\n        /// </summary>\n        /// <param name=\"navigation\">The navigation object.</param>\n        /// <param name=\"target\">The navigation target</param>\n        public static void RequestNavigate(this INavigateAsync navigation, string target)\n        {\n            RequestNavigate(navigation, target, nr => { });\n        }\n\n        /// <summary>\n        /// Initiates navigation to the target specified by the <paramref name=\"target\"/>.\n        /// </summary>\n        /// <param name=\"navigation\">The navigation object.</param>\n        /// <param name=\"target\">The navigation target</param>\n        /// <param name=\"navigationCallback\">The callback executed when the navigation request is completed.</param>\n        public static void RequestNavigate(this INavigateAsync navigation, string target, Action<NavigationResult> navigationCallback)\n        {\n            if (navigation == null)\n                throw new ArgumentNullException(nameof(navigation));\n\n            if (target == null)\n                throw new ArgumentNullException(nameof(target));\n\n            var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);\n\n            navigation.RequestNavigate(targetUri, navigationCallback);\n        }\n\n        /// <summary>\n        /// Initiates navigation to the target specified by the <see cref=\"Uri\"/>.\n        /// </summary>\n        /// <param name=\"navigation\">The navigation object.</param>\n        /// <param name=\"target\">The navigation target</param>\n        public static void RequestNavigate(this INavigateAsync navigation, Uri target)\n        {\n            if (navigation == null)\n                throw new ArgumentNullException(nameof(navigation));","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Prism.Core/Navigation/Regions/NavigationAsyncExtensions.cs#L25-L61","documentation":"The RequestNavigate extension overload (INavigateAsync, string target, Action<NavigationResult> callback) validates its arguments before parsing the target and delegates to navigation.RequestNavigate. Passing null for the navigation object throws ArgumentNullException(nameof(navigation)).","triggerScenarios":"Calling RequestNavigate(null, \"SomeView\", callback) — e.g. the region or INavigateAsync instance was never initialized or a null return from a factory was passed through.","commonSituations":"Region not yet attached (region lookup returned null and was passed in); calling the extension before region creation; unit tests passing null mocks.","solutions":["Ensure the INavigateAsync instance (typically an IRegion) is non-null before calling — check region resolution succeeded.","Guard the source of the region (e.g. regionManager.Regions[\"X\"] existence) before invoking.","If region may not exist, use regionManager.RegisterViewWithRegion or check Regions.ContainsRegionWithName first."],"exampleFix":"// before\nregionManager.Regions[\"MainRegion\"].RequestNavigate(\"Home\"); // may be null if region missing\n// after\nif (regionManager.Regions.ContainsRegionWithName(\"MainRegion\"))\n    regionManager.Regions[\"MainRegion\"].RequestNavigate(\"Home\");","handlingStrategy":"type-guard","validationCode":"if (navigation == null)\n    throw new InvalidOperationException(\"Region not available for navigation\");","typeGuard":"static bool CanNavigate(IRegionManager rm, string regionName) =>\n    rm != null && rm.Regions.ContainsRegionWithName(regionName);","tryCatchPattern":"try { region.RequestNavigate(target, result => {}); }\ncatch (ArgumentNullException ex) { logger.LogWarning(ex, \"Navigation target not initialized\"); }","preventionTips":["Resolve regions through IRegionManager at call time, never cache raw region references.","Check ContainsRegionWithName before navigating.","Defer navigation until regions are attached."],"tags":["prism","navigation","argument-null","extension-method"],"backgroundTag":"null-argument","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}