{"record":{"id":"81ec92c8503a054f","repo":"PrismLibrary/Prism","slug":"argumentnullexception-for-regionname","errorCode":null,"errorMessage":"ArgumentNullException for 'regionName'","messagePattern":"ArgumentNullException for 'regionName'","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs","lineNumber":132,"sourceCode":"    /// <param name=\"regionName\">The name of the region to call Navigate on.</param>\n    /// <param name=\"target\">The URI of the content to display.</param>\n    /// <param name=\"navigationCallback\">The navigation callback.</param>\n    public void RequestNavigate(string regionName, Uri target, Action<NavigationResult> navigationCallback) =>\n        RequestNavigate(regionName, target, navigationCallback, null);\n\n    /// <summary>\n    /// This method allows an <see cref=\"IRegionManager\"/> to locate a specified region and navigate in it to the specified target <see cref=\"Uri\"/>, passing a navigation callback and an instance of <see cref=\"INavigationParameters\"/>, which holds a collection of object parameters.\n    /// </summary>\n    /// <param name=\"regionName\">The name of the region where the navigation will occur.</param>\n    /// <param name=\"target\">A <see cref=\"Uri\"/> that represents the target where the region will navigate.</param>\n    /// <param name=\"navigationCallback\">The navigation callback that will be executed after the navigation is completed.</param>\n    /// <param name=\"navigationParameters\">An instance of <see cref=\"INavigationParameters\"/>, which holds a collection of object parameters.</param>\n    public void RequestNavigate(string regionName, Uri target, Action<NavigationResult> navigationCallback, INavigationParameters navigationParameters)\n    {\n        try\n        {\n            if (string.IsNullOrEmpty(regionName))\n                throw new ArgumentNullException(nameof(regionName));\n\n            var region = Regions[regionName];\n\n            if (region is null)\n                throw new Exception(\"Region not Found\");\n\n            region.NavigationService.RequestNavigate(target, navigationCallback, navigationParameters);\n        }\n        catch (Exception ex)\n        {\n            var navigationContext = new NavigationContext(null, target, navigationParameters);\n            navigationCallback?.Invoke(new NavigationResult(navigationContext, ex));\n        }\n    }\n\n    ///// <summary>\n    ///// Provides a new item for the region based on the supplied candidate target contract name.\n    ///// </summary>","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs#L114-L150","documentation":"RegionManager.RequestNavigate throws ArgumentNullException for regionName when the regionName string is null or empty. A navigation target region must be specified; RequestNavigate wraps the throw in its try block and converts it into a failed NavigationResult via the callback.","triggerScenarios":"Calling any RequestNavigate overload with regionName == null or \"\" — e.g. building the region name dynamically from configuration or a route string that came back empty.","commonSituations":"A settings/config value or deep-link segment that supplies the region name being empty; string.Split producing an empty first token; binding a region name property that was never initialized.","solutions":["Validate the region name with string.IsNullOrEmpty before calling RequestNavigate.","Fix the upstream source (config, route parsing, property) that yields the empty name.","Handle the failure in the NavigationResult callback, since the exception is caught and reported there."],"exampleFix":"// before\nregionManager.RequestNavigate(settings.Region, new Uri(\"Detail\", UriKind.Relative), result => { });\n// after\nif (!string.IsNullOrEmpty(settings.Region))\n    regionManager.RequestNavigate(settings.Region, new Uri(\"Detail\", UriKind.Relative), result => { });","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(regionName))\n    throw new ArgumentException(\"Region name is required\", nameof(regionName));","typeGuard":"bool IsValidRegionName(string s) => !string.IsNullOrWhiteSpace(s);","tryCatchPattern":"regionManager.RequestNavigate(regionName, target, result =>\n{\n    if (!result.Success)\n        Console.WriteLine($\"Navigation failed: {result.Exception?.Message}\");\n}, parameters);","preventionTips":["Validate region names from config/routes before navigating","Handle navigation failures in the NavigationResult callback","Use string constants for region names"],"tags":["prism","regions","navigation","argumentnullexception"],"backgroundTag":"missing-required-argument","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}