PrismLibrary/Prism · error · ArgumentNullException
configureSegment
Error message
configureSegment
What it means
TabbedSegmentBuilder.CreateTab(Action<ICreateTabBuilder>) validates its configureSegment delegate with ArgumentNullException. Passing a null delegate throws immediately; the exception's parameter name is "configureSegment".
Solutions
- Always pass a non-null delegate; if no configuration is needed pass a no-op: `b => { }`.
- Guard your own helper methods before forwarding the delegate to CreateTab.
- Fix the caller that computes the delegate to ensure it isn't null.
Example fix
// before
tabbedBuilder.CreateTab(null); // ArgumentNullException
// after
tabbedBuilder.CreateTab(b => { });
// or guard:
if (configure is null) throw new ArgumentNullException(nameof(configure)); Defensive patterns
Strategy: validation
Validate before calling
if (configureSegment is null)
throw new ArgumentNullException(nameof(configureSegment));
tabbedBuilder.CreateTab(configureSegment); Type guard
bool HasConfigurator(Action<ICreateTabBuilder> a) => a is not null;
Try / catch
try { tabbedBuilder.CreateTab(configureSegment); }
catch (ArgumentNullException ex) when (ex.ParamName == "configureSegment")
{
tabbedBuilder.CreateTab(b => { }); // no-op configuration
} Prevention
- Default optional Action parameters to `b => { }` instead of null
- Never forward possibly-null delegates into Prism builder APIs
- Enable nullable reference types (Action<ICreateTabBuilder>?) to catch this at compile time
When it happens
Trigger: Calling `tabbedBuilder.CreateTab(null)` or forwarding a null callback from your own helper method into CreateTab.
Common situations: Wrapping CreateTab in a helper with an optional Action parameter that defaults to null; dynamic code paths that skip building the delegate.
Related errors
- The builder does not implement IRegistryAware
- NavigationException.NoPageIsRegistered
- No Registration found to select tab
- The page type ' ' is not supported.
- Unable to determine the current page.
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/c4785c49b7c32888.
Report an issue: GitHub.
Appendix: source
Thrown at src/Maui/Prism.Maui/Navigation/Builder/TabbedSegmentBuilder.cs:63
public string Segment => BuildSegment();
public ITabbedSegmentBuilder AddSegmentParameter(string key, object value)
{
_parameters.Add(key, value);
return this;
}
public ITabbedSegmentBuilder UseModalNavigation(bool useModalNavigation)
{
return AddSegmentParameter(KnownNavigationParameters.UseModalNavigation, useModalNavigation);
}
public ITabbedSegmentBuilder CreateTab(Action<ICreateTabBuilder> configureSegment)
{
if (configureSegment is null)
{
throw new ArgumentNullException(nameof(configureSegment));
}
var builder = new CreateTabBuilder(((IRegistryAware)_builder).Registry);
configureSegment(builder);
return AddSegmentParameter(KnownNavigationParameters.CreateTab, builder.Segment);
}
public ITabbedSegmentBuilder SelectedTab(string segmentName)
{
return AddSegmentParameter(KnownNavigationParameters.SelectedTab, segmentName);
}
public ITabbedSegmentBuilder Title(string title)
{
return AddSegmentParameter(KnownNavigationParameters.Title, title);
}
private string BuildSegment()View on GitHub (pinned to 358118cd64)