PrismLibrary/Prism · error · ArgumentNullException
ArgumentNullException(nameof(navigationContext))
Error message
ArgumentNullException(nameof(navigationContext))
What it means
The RegionNavigationEventArgs constructor requires a NavigationContext and throws ArgumentNullException when null is passed. Every region navigation event argument must carry the context that describes the navigation.
Solutions
- Only construct the event args with a valid NavigationContext obtained from the navigation service
- In custom services, guard against null context before raising events
- In tests, build a NavigationContext via a NavigationJournal/Uri rather than passing null
Example fix
// before
eventArgs = new RegionNavigationEventArgs(null);
// after
var ctx = new NavigationContext(navigationService, new Uri("/View", UriKind.Relative));
eventArgs = new RegionNavigationEventArgs(ctx); Defensive patterns
Strategy: type-guard
Validate before calling
if (navigationContext == null) return; // or throw InvalidOperationException with context
Type guard
bool IsValid(RegionNavigationEventArgs a) => a?.NavigationContext != null;
Try / catch
try { RaiseNavEvent(new RegionNavigationEventArgs(ctx)); }
catch (ArgumentNullException ex) when (ex.ParamName == "navigationContext") { log.Error("Navigation raised without context"); } Prevention
- Never construct navigation event args manually unless implementing a custom INavigationService
- Always derive event args from the current navigation context
When it happens
Trigger: Constructing RegionNavigationEventArgs directly (e.g. raising the region's NavigationService events manually or in tests) and passing null instead of an active NavigationContext.
Common situations: Custom INavigationService implementations or unit test mocks that raise RegionNavigation events without a context; refactoring where context is only available after an async boundary.
Related errors
- ArgumentNullException(nameof(navigationContext))
- Resources.NavigationModeNotAvailable
- ArgumentNullException("delegate")
- ArgumentNullException for 'regionName'
- ArgumentNullException(nameof(action))
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/b766ac72aaa80070.
Report an issue: GitHub.
Appendix: source
Thrown at src/Prism.Core/Navigation/Regions/RegionNavigationEventArgs.cs:16
using System;
namespace Prism.Navigation.Regions
{
/// <summary>
/// EventArgs used with the Navigated event.
/// </summary>
public class RegionNavigationEventArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="RegionNavigationEventArgs"/> class.
/// </summary>
/// <param name="navigationContext">The navigation context.</param>
public RegionNavigationEventArgs(NavigationContext navigationContext)
{
NavigationContext = navigationContext ?? throw new ArgumentNullException(nameof(navigationContext));
}
/// <summary>
/// Gets the navigation context.
/// </summary>
/// <value>The navigation context.</value>
public NavigationContext NavigationContext { get; }
/// <summary>
/// Gets the navigation URI
/// </summary>
/// <value>The URI.</value>
/// <remarks>
/// This is a convenience accessor around NavigationContext.Uri.
/// </remarks>
public Uri Uri => NavigationContext.Uri;
}
}View on GitHub (pinned to 358118cd64)