PrismLibrary/Prism · error · ArgumentNullException
ArgumentNullException(nameof(navigation))
Error message
ArgumentNullException(nameof(navigation))
What it means
The RequestNavigate extension overload (INavigateAsync, string target, Action<NavigationResult> callback) validates its arguments before parsing the target and delegates to navigation.RequestNavigate. Passing null for the navigation object throws ArgumentNullException(nameof(navigation)).
Solutions
- Ensure the INavigateAsync instance (typically an IRegion) is non-null before calling — check region resolution succeeded.
- Guard the source of the region (e.g. regionManager.Regions["X"] existence) before invoking.
- If region may not exist, use regionManager.RegisterViewWithRegion or check Regions.ContainsRegionWithName first.
Example fix
// before
regionManager.Regions["MainRegion"].RequestNavigate("Home"); // may be null if region missing
// after
if (regionManager.Regions.ContainsRegionWithName("MainRegion"))
regionManager.Regions["MainRegion"].RequestNavigate("Home"); Defensive patterns
Strategy: type-guard
Validate before calling
if (navigation == null)
throw new InvalidOperationException("Region not available for navigation"); Type guard
static bool CanNavigate(IRegionManager rm, string regionName) =>
rm != null && rm.Regions.ContainsRegionWithName(regionName); Try / catch
try { region.RequestNavigate(target, result => {}); }
catch (ArgumentNullException ex) { logger.LogWarning(ex, "Navigation target not initialized"); } Prevention
- Resolve regions through IRegionManager at call time, never cache raw region references.
- Check ContainsRegionWithName before navigating.
- Defer navigation until regions are attached.
When it happens
Trigger: Calling RequestNavigate(null, "SomeView", callback) — e.g. the region or INavigateAsync instance was never initialized or a null return from a factory was passed through.
Common situations: Region not yet attached (region lookup returned null and was passed in); calling the extension before region creation; unit tests passing null mocks.
Related errors
- ArgumentNullException(nameof(target))
- ArgumentNullException for 'regionName'
- ArgumentNullException for 'regionTarget'
- ArgumentNullException for 'target'
- ArgumentNullException for 'view'
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/408d82398e33b663.
Report an issue: GitHub.
Appendix: source
Thrown at src/Prism.Core/Navigation/Regions/NavigationAsyncExtensions.cs:43
/// Initiates navigation to the target specified by the <paramref name="target"/>.
/// </summary>
/// <param name="navigation">The navigation object.</param>
/// <param name="target">The navigation target</param>
public static void RequestNavigate(this INavigateAsync navigation, string target)
{
RequestNavigate(navigation, target, nr => { });
}
/// <summary>
/// Initiates navigation to the target specified by the <paramref name="target"/>.
/// </summary>
/// <param name="navigation">The navigation object.</param>
/// <param name="target">The navigation target</param>
/// <param name="navigationCallback">The callback executed when the navigation request is completed.</param>
public static void RequestNavigate(this INavigateAsync navigation, string target, Action<NavigationResult> navigationCallback)
{
if (navigation == null)
throw new ArgumentNullException(nameof(navigation));
if (target == null)
throw new ArgumentNullException(nameof(target));
var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
navigation.RequestNavigate(targetUri, navigationCallback);
}
/// <summary>
/// Initiates navigation to the target specified by the <see cref="Uri"/>.
/// </summary>
/// <param name="navigation">The navigation object.</param>
/// <param name="target">The navigation target</param>
public static void RequestNavigate(this INavigateAsync navigation, Uri target)
{
if (navigation == null)
throw new ArgumentNullException(nameof(navigation));View on GitHub (pinned to 358118cd64)