PrismLibrary/Prism · error · ArgumentNullException
ArgumentNullException for 'regionName'
Error message
ArgumentNullException for 'regionName'
What it means
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.
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.
Example fix
// before
regionManager.RequestNavigate(settings.Region, new Uri("Detail", UriKind.Relative), result => { });
// after
if (!string.IsNullOrEmpty(settings.Region))
regionManager.RequestNavigate(settings.Region, new Uri("Detail", UriKind.Relative), result => { }); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(regionName))
throw new ArgumentException("Region name is required", nameof(regionName)); Type guard
bool IsValidRegionName(string s) => !string.IsNullOrWhiteSpace(s);
Try / catch
regionManager.RequestNavigate(regionName, target, result =>
{
if (!result.Success)
Console.WriteLine($"Navigation failed: {result.Exception?.Message}");
}, parameters); Prevention
- Validate region names from config/routes before navigating
- Handle navigation failures in the NavigationResult callback
- Use string constants for region names
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Object reference not set (ArgumentNullException for…
- Region not Found
- The page type ' ' is not supported.
- Unable to determine the current page.
- NavigationException.NoPageIsRegistered
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/81ec92c8503a054f.
Report an issue: GitHub.
Appendix: source
Thrown at src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs:132
/// <param name="regionName">The name of the region to call Navigate on.</param>
/// <param name="target">The URI of the content to display.</param>
/// <param name="navigationCallback">The navigation callback.</param>
public void RequestNavigate(string regionName, Uri target, Action<NavigationResult> navigationCallback) =>
RequestNavigate(regionName, target, navigationCallback, null);
/// <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>View on GitHub (pinned to 358118cd64)