PrismLibrary/Prism · error · ArgumentNullException

source

Error message

source

What it means

DoNavigate validates the navigation target Uri before building the NavigationContext. A null source Uri means there is nothing to navigate to, so Prism throws ArgumentNullException immediately instead of failing later inside content loading.

Solutions

  1. Ensure the Uri passed to RequestNavigate is non-null before calling.
  2. Use Uri.TryCreate and check success before navigating.
  3. Validate deep-link/config data that feeds the Uri.

Example fix

// before
regionNavigationService.RequestNavigate(uri, callback, parameters); // uri may be null
// after
if (uri == null) throw new ArgumentException("Navigation target is required");
regionNavigationService.RequestNavigate(uri, callback, parameters);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(targetString) || !Uri.TryCreate(targetString, UriKind.RelativeOrAbsolute, out var uri))
    throw new ArgumentException($"Invalid navigation target: {targetString}");
navigationService.RequestNavigate(uri, callback, parameters);

Type guard

bool IsValidTarget(Uri u) => u is not null;

Try / catch

try
{
    navigationService.RequestNavigate(uri, result => OnNavigated(result));
}
catch (ArgumentNullException)
{
    // handle missing navigation target
}

Prevention

When it happens

Trigger: Calling RequestNavigate(null, callback, parameters) or passing a Uri variable that failed to initialize (e.g. Uri.TryCreate result ignored).

Common situations: Building the target Uri from a string that was null/empty; navigation requests assembled from configuration or deep-link data that is missing.

Related errors


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

Appendix: source

Thrown at src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationService.cs:106

    public void RequestNavigate(Uri target, Action<NavigationResult> navigationCallback, INavigationParameters regionParameters)
    {
        if (navigationCallback == null)
            throw new ArgumentNullException(nameof(navigationCallback));

        try
        {
            DoNavigate(target, navigationCallback, regionParameters);
        }
        catch (Exception e)
        {
            NotifyNavigationFailed(new NavigationContext(this, target), navigationCallback, e);
        }
    }

    private void DoNavigate(Uri source, Action<NavigationResult> navigationCallback, INavigationParameters regionParameters)
    {
        if (source == null)
            throw new ArgumentNullException(nameof(source));

        if (Region == null)
            throw new InvalidOperationException(Resources.NavigationServiceHasNoRegion);

        _currentNavigationContext = new NavigationContext(this, source, regionParameters);

        // starts querying the active views
        RequestCanNavigateFromOnCurrentlyActiveView(
            _currentNavigationContext,
            navigationCallback,
            Region.ActiveViews.OfType<VisualElement>().ToArray(),
            0);
    }

    private void RequestCanNavigateFromOnCurrentlyActiveView(
        NavigationContext navigationContext,
        Action<NavigationResult> navigationCallback,
        VisualElement[] activeViews,

View on GitHub (pinned to 358118cd64)