{"record":{"id":"abf7d1da848f5a82","repo":"PrismLibrary/Prism","slug":"region-not-found","errorCode":null,"errorMessage":"Region not Found","messagePattern":"Region not Found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs","lineNumber":137,"sourceCode":"\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>\n    ///// <param name=\"candidateTargetContract\">The target contract to build.</param>\n    ///// <returns>An instance of an item to put into the <see cref=\"IRegion\"/>.</returns>\n    //protected virtual VisualElement CreateNewRegionItem(string candidateTargetContract)\n    //{\n    //    try","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs#L119-L155","documentation":"After resolving Regions[regionName], RequestNavigate throws a plain Exception(\"Region not Found\") when the indexer returns null — the name is valid as a key lookup but no region is registered under it. The exception is caught internally and delivered as a failed NavigationResult with the exception attached.","triggerScenarios":"Calling regionManager.RequestNavigate(regionName, uri, callback, parameters) where Regions.ContainsRegionWithName(regionName) is false; the callback receives a NavigationResult with Success == false and Context/Exception set.","commonSituations":"Navigating to a region in a view that hasn't been loaded/created yet; region name typo; region destroyed after its host page was popped from the navigation stack.","solutions":["Inspect the NavigationResult in the callback and check result.Exception for the 'Region not Found' message.","Verify the region exists (ContainsRegionWithName) and its host view is loaded before navigating.","Use RegisterViewWithRegion so the region is created before navigation is requested."],"exampleFix":"// before\nregionManager.RequestNavigate(\"Details\", uri, result => { });\n// after\nregionManager.RequestNavigate(\"Details\", uri, result =>\n{\n    if (!result.Success)\n        Console.WriteLine($\"Navigation failed: {result.Exception?.Message}\");\n});","handlingStrategy":"try-catch","validationCode":"if (!regionManager.Regions.ContainsRegionWithName(regionName))\n    throw new InvalidOperationException($\"Region '{regionName}' not found\");","typeGuard":"bool RegionExists(IRegionManager rm, string name) => rm.Regions.ContainsRegionWithName(name);","tryCatchPattern":"regionManager.RequestNavigate(regionName, target, result =>\n{\n    if (!result.Success)\n        Console.WriteLine($\"{result.Context ?? result.Exception?.Message}\");\n}, parameters);","preventionTips":["Check NavigationResult.Success on every navigation","Ensure the target region's host view is loaded before navigating","Track region lifetime relative to page navigation stack"],"tags":["prism","regions","navigation","region-not-found"],"backgroundTag":"resource-not-found","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"}