PrismLibrary/Prism · error · ArgumentNullException

regionNavigationContentLoader

Error message

regionNavigationContentLoader

What it means

Thrown by the RegionNavigationService constructor when the IRegionNavigationContentLoader dependency is null. The content loader is responsible for creating/locating the target view for a navigation request, so the service cannot navigate without it. Fail-fast guard on a required constructor argument.

Solutions

  1. Pass a valid IRegionNavigationContentLoader (e.g. RegionNavigationContentLoader registered in the container).
  2. Ensure Prism's default registrations are applied via UsePrism/PrismAppBuilder so the loader is resolvable.
  3. Fix argument ordering in manual constructions.

Example fix

// before
var svc = new RegionNavigationService(container, null, journal);
// after
var svc = new RegionNavigationService(container, new RegionNavigationContentLoader(container), journal);
Defensive patterns

Strategy: validation

Validate before calling

if (loader is null) throw new ArgumentNullException(nameof(loader));
var svc = new RegionNavigationService(container, loader, journal);

Type guard

bool IsValid(IRegionNavigationContentLoader l) => l is not null;

Prevention

When it happens

Trigger: Calling new RegionNavigationService(container, null, journal) or resolving a container registration that yields null for IRegionNavigationContentLoader.

Common situations: Unit tests constructing the service by hand, missing RegionNavigationContentLoader registration in a custom container setup, swapped constructor arguments.

Related errors


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

Appendix: source

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

/// <summary>
/// Provides navigation for regions.
/// </summary>
public class RegionNavigationService : IRegionNavigationService
{
    private readonly IContainerProvider _container;
    private readonly IRegionNavigationContentLoader _regionNavigationContentLoader;
    private NavigationContext _currentNavigationContext;

    /// <summary>
    /// Initializes a new instance of the <see cref="RegionNavigationService"/> class.
    /// </summary>
    /// <param name="container">The <see cref="IContainerExtension" />.</param>
    /// <param name="regionNavigationContentLoader">The navigation target handler.</param>
    /// <param name="journal">The journal.</param>
    public RegionNavigationService(IContainerExtension container, IRegionNavigationContentLoader regionNavigationContentLoader, IRegionNavigationJournal journal)
    {
        _container = container ?? throw new ArgumentNullException(nameof(container));
        _regionNavigationContentLoader = regionNavigationContentLoader ?? throw new ArgumentNullException(nameof(regionNavigationContentLoader));
        Journal = journal ?? throw new ArgumentNullException(nameof(journal));
        Journal.NavigationTarget = this;
    }

    /// <summary>
    /// Gets or sets the region.
    /// </summary>
    /// <value>The region.</value>
    public IRegion Region { get; set; }

    /// <summary>
    /// Gets the journal.
    /// </summary>
    /// <value>The journal.</value>
    public IRegionNavigationJournal Journal { get; private set; }

    /// <summary>
    /// Raised when the region is about to be navigated to content.

View on GitHub (pinned to 358118cd64)