PrismLibrary/Prism · error · ArgumentNullException

container

Error message

container

What it means

Thrown by the RegionNavigationService constructor when the IContainerExtension dependency is passed as null. Prism requires the container to resolve views and services during region navigation, so a null container makes the service unusable. It is an eager fail-fast guard for an invalid constructor argument.

Solutions

  1. Register IContainerExtension in the container before the region navigation service is resolved (done automatically by PrismAppBuilder / UsePrism).
  2. Pass the actual IContainerExtension instance from your container extension when constructing manually.
  3. Check constructor argument order so the container is the first parameter.

Example fix

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

Strategy: validation

Validate before calling

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

Type guard

bool IsValid(IContainerExtension c) => c is not null;

Prevention

When it happens

Trigger: Calling new RegionNavigationService(null, loader, journal) or a DI container resolving a null IContainerExtension registration when constructing the region navigation service.

Common situations: Manual instantiation of Prism internals in unit tests, custom container adapters that forget to register IContainerExtension, wrong constructor argument order.

Related errors


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

Appendix: source

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

/// <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>

View on GitHub (pinned to 358118cd64)