PrismLibrary/Prism · error · Exception

Region not Found

Error message

Region not Found

What it means

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.

Solutions

  1. Inspect the NavigationResult in the callback and check result.Exception for the 'Region not Found' message.
  2. Verify the region exists (ContainsRegionWithName) and its host view is loaded before navigating.
  3. Use RegisterViewWithRegion so the region is created before navigation is requested.

Example fix

// before
regionManager.RequestNavigate("Details", uri, result => { });
// after
regionManager.RequestNavigate("Details", uri, result =>
{
    if (!result.Success)
        Console.WriteLine($"Navigation failed: {result.Exception?.Message}");
});
Defensive patterns

Strategy: try-catch

Validate before calling

if (!regionManager.Regions.ContainsRegionWithName(regionName))
    throw new InvalidOperationException($"Region '{regionName}' not found");

Type guard

bool RegionExists(IRegionManager rm, string name) => rm.Regions.ContainsRegionWithName(name);

Try / catch

regionManager.RequestNavigate(regionName, target, result =>
{
    if (!result.Success)
        Console.WriteLine($"{result.Context ?? result.Exception?.Message}");
}, parameters);

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15). Data as JSON: /api/errors/abf7d1da848f5a82. Report an issue: GitHub.

Appendix: source

Thrown at src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs:137

    /// <summary>
    /// 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.
    /// </summary>
    /// <param name="regionName">The name of the region where the navigation will occur.</param>
    /// <param name="target">A <see cref="Uri"/> that represents the target where the region will navigate.</param>
    /// <param name="navigationCallback">The navigation callback that will be executed after the navigation is completed.</param>
    /// <param name="navigationParameters">An instance of <see cref="INavigationParameters"/>, which holds a collection of object parameters.</param>
    public void RequestNavigate(string regionName, Uri target, Action<NavigationResult> navigationCallback, INavigationParameters navigationParameters)
    {
        try
        {
            if (string.IsNullOrEmpty(regionName))
                throw new ArgumentNullException(nameof(regionName));

            var region = Regions[regionName];

            if (region is null)
                throw new Exception("Region not Found");

            region.NavigationService.RequestNavigate(target, navigationCallback, navigationParameters);
        }
        catch (Exception ex)
        {
            var navigationContext = new NavigationContext(null, target, navigationParameters);
            navigationCallback?.Invoke(new NavigationResult(navigationContext, ex));
        }
    }

    ///// <summary>
    ///// Provides a new item for the region based on the supplied candidate target contract name.
    ///// </summary>
    ///// <param name="candidateTargetContract">The target contract to build.</param>
    ///// <returns>An instance of an item to put into the <see cref="IRegion"/>.</returns>
    //protected virtual VisualElement CreateNewRegionItem(string candidateTargetContract)
    //{
    //    try

View on GitHub (pinned to 358118cd64)