PrismLibrary/Prism · error · ArgumentException
Resources.RegionNotFound (formatted with regionName)
Error message
Resources.RegionNotFound (formatted with regionName)
What it means
RegionManager.AddToRegion(string regionName, string targetName) throws ArgumentException (parameter regionName) when no region with that name is registered — Regions.ContainsRegionWithName(regionName) is false. Resources.RegionNotFound is formatted with the requested name.
Solutions
- Verify the region name matches exactly the RegionName registered in XAML/code (case-sensitive).
- Ensure the view containing the region has been created/loaded before calling AddToRegion, or use RegisterViewWithRegion instead.
- Check that a region adapter exists for the hosting control so the region is actually created.
Example fix
// before
regionManager.AddToRegion("MainreGion", "MyView"); // typo/case mismatch
// after
if (regionManager.Regions.ContainsRegionWithName("MainRegion"))
regionManager.AddToRegion("MainRegion", "MyView"); Defensive patterns
Strategy: validation
Validate before calling
if (!regionManager.Regions.ContainsRegionWithName(regionName))
throw new InvalidOperationException($"Region '{regionName}' is not registered");
regionManager.AddToRegion(regionName, targetName); Type guard
bool RegionExists(IRegionManager rm, string name) => rm.Regions.ContainsRegionWithName(name);
Try / catch
try { regionManager.AddToRegion(regionName, targetName); }
catch (ArgumentException ex) { Console.WriteLine($"Region '{regionName}' not found: {ex.Message}"); } Prevention
- Use string constants for region names
- Register views with RegisterViewWithRegion instead of imperative AddToRegion when possible
- Ensure host views are created before targeting their regions
When it happens
Trigger: Calling regionManager.AddToRegion("SomeRegion", "ViewName") when no region named "SomeRegion" has been registered or the XAML region name differs in case/spelling.
Common situations: Typo or case mismatch between the RegionName in XAML and the string used in code; region not yet created because the containing view hasn't loaded; Prism.MongoDb... no — region adapters missing for the target control so no region was instantiated.
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
- Resources.RegionNameExistsException (formatted with…
- Resources.RegionManagerWithDifferentNameException…
- Region not Found
- Layout 's Children property is not empty. This control is…
- regionName
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/93df5540df5af05a.
Report an issue: GitHub.
Appendix: source
Thrown at src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs:37
Regions = new RegionCollection(this);
}
/// <summary>
/// Gets a collection of <see cref="IRegion"/> that identify each region by name. You can use this collection to add or remove regions to the current region manager.
/// </summary>
/// <value>A <see cref="IRegionCollection"/> with all the registered regions.</value>
public IRegionCollection Regions { get; }
/// <summary>
/// Add a view to the Views collection of a Region. Note that the region must already exist in this <see cref="IRegionManager"/>.
/// </summary>
/// <param name="regionName">The name of the region to add a view to</param>
/// <param name="targetName">The view to add to the views collection</param>
/// <returns>The RegionManager, to easily add several views. </returns>
public IRegionManager AddToRegion(string regionName, string targetName)
{
if (!Regions.ContainsRegionWithName(regionName))
throw new ArgumentException(string.Format(Thread.CurrentThread.CurrentCulture, Resources.RegionNotFound, regionName), nameof(regionName));
var region = Regions[regionName];
return region.Add(targetName);
}
/// <summary>
/// Add a view to the Views collection of a Region. Note that the region must already exist in this <see cref="IRegionManager"/>.
/// </summary>
/// <param name="regionName">The name of the region to add a view to</param>
/// <param name="view">The view to add to the views collection</param>
/// <returns>The RegionManager, to easily add several views. </returns>
public IRegionManager AddToRegion(string regionName, object view)
{
if (!Regions.ContainsRegionWithName(regionName))
throw new ArgumentException(string.Format(Thread.CurrentThread.CurrentCulture, Resources.RegionNotFound, regionName), nameof(regionName));
return Regions[regionName].Add(view);
}View on GitHub (pinned to 358118cd64)