PrismLibrary/Prism · error · Exception

The builder does not implement IRegistryAware

Error message

The builder does not implement IRegistryAware

What it means

The TabbedSegmentBuilder constructor requires the supplied INavigationBuilder to implement IRegistryAware so it can look up TabbedPage registrations. If it does not, a plain Exception is thrown at construction time. Prism's own builders implement this interface; third-party or test-double builders typically do not.

Solutions

  1. Ensure the builder passed to TabbedSegmentBuilder is Prism's own INavigationBuilder (which implements IRegistryAware).
  2. Implement IRegistryAware on custom builders and delegate Registry to the wrapped builder.
  3. Register TabbedPage in the view registry so the subsequent registration lookup succeeds.

Example fix

// before
public class FakeNavBuilder : INavigationBuilder { ... }
var tabBuilder = new TabbedSegmentBuilder(fakeNavBuilder); // throws
// after
public class FakeNavBuilder : INavigationBuilder, IRegistryAware
{
    public IViewRegistry Registry { get; set; }
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (navBuilder is not IRegistryAware)
    throw new InvalidOperationException("INavigationBuilder must implement IRegistryAware to build TabbedSegments");

Type guard

bool SupportsTabbedSegment(INavigationBuilder b) => b is IRegistryAware;

Try / catch

try { var tab = new TabbedSegmentBuilder(navBuilder); }
catch (Exception ex) when (ex.Message.Contains("IRegistryAware"))
{
    // swap in Prism's stock INavigationBuilder implementation
}

Prevention

When it happens

Trigger: Constructing `new TabbedSegmentBuilder(builder)` where `builder` is an INavigationBuilder implementation lacking IRegistryAware - e.g. a mock or custom INavigationBuilder used in tests or a derived builder.

Common situations: Testing Prism navigation with hand-rolled INavigationBuilder fakes; subclassing Prism's NavigationBuilder in a version where IRegistryAware did not exist; replacing navigation services via DI with a simplified implementation.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/Maui/Prism.Maui/Navigation/Builder/TabbedSegmentBuilder.cs:17

using Prism.Common;
using Prism.Mvvm;

namespace Prism.Navigation.Builder;

internal class TabbedSegmentBuilder : ITabbedSegmentBuilder, IConfigurableSegmentName, IUriSegment, IRegistryAware
{
    private INavigationParameters _parameters { get; }
    private INavigationBuilder _builder { get; }

    public TabbedSegmentBuilder(INavigationBuilder builder)
    {
        _builder = builder;
        _parameters = new NavigationParameters();

        if (builder is not IRegistryAware registryAware)
            throw new Exception("The builder does not implement IRegistryAware");

        var registrations = registryAware.Registry.ViewsOfType(typeof(TabbedPage));
        if (!registrations.Any())
            throw new NavigationException(NavigationException.NoPageIsRegistered, nameof(TabbedPage));

        var registration = registrations.Last();
        SegmentName = registration.Name;
    }

    public TabbedSegmentBuilder(INavigationBuilder builder, string segmentName)
    {
        _builder = builder;
        _parameters = new NavigationParameters();

        if (builder is not IRegistryAware registryAware)
            throw new Exception("The builder does not implement IRegistryAware");

        var registration = registryAware.Registry.ViewsOfType(typeof(TabbedPage)).FirstOrDefault(x => x.Name == segmentName);

View on GitHub (pinned to 358118cd64)