PrismLibrary/Prism · error · ArgumentNullException
regionName
Error message
regionName
What it means
RegionAdapterBase<T>.Initialize assigns region.Name = regionName, throwing ArgumentNullException when the regionName argument is null. Every region adapter funnels through this method, so a null region name during region initialization is rejected here.
Solutions
- Ensure the RegionManager.RegionName value (or the regionName argument) is a non-null, non-empty string before the view is attached
- Guard any bound property feeding RegionName with a fallback value in the ViewModel
- If registering regions programmatically, pass a literal or validated region name to Initialize
Example fix
// before
stackLayout.SetValue(RegionManager.RegionNameProperty, viewModel.RegionName); // null
// after
if (!string.IsNullOrEmpty(viewModel.RegionName))
stackLayout.SetValue(RegionManager.RegionNameProperty, viewModel.RegionName); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(regionName)) throw new ArgumentException("Region name must be non-empty", nameof(regionName)); Try / catch
try { adapter.Initialize(target, regionName); }
catch (ArgumentNullException) { /* log: region name was null; fix the bound RegionName value */ } Prevention
- Never bind RegionManager.RegionName to a property that can be null; provide a default
- Validate region names at ViewModel construction time
- Use nameof() or constants for region names to avoid typos/nulls
When it happens
Trigger: Calling IRegionAdapter.Initialize(regionTarget, null), typically reached when a control's RegionManager.RegionName attached property is set to null (or bound to a null value) and the region registration pipeline calls Initialize with that value.
Common situations: Binding RegionManager.RegionName to a ViewModel property that is null at bind time; programmatically calling region registration helpers without a name; renaming a region and leaving the bound property unset.
Related errors
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/8ad5bb6a3329021b.
Report an issue: GitHub.
Appendix: source
Thrown at src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterBase.cs:40
}
/// <summary>
/// Gets or sets the factory used to create the region behaviors to attach to the created regions.
/// </summary>
protected IRegionBehaviorFactory RegionBehaviorFactory { get; set; }
/// <summary>
/// Adapts an object and binds it to a new <see cref="IRegion"/>.
/// </summary>
/// <param name="regionTarget">The object to adapt.</param>
/// <param name="regionName">The name of the region to be created.</param>
/// <returns>The new instance of <see cref="IRegion"/> that the <paramref name="regionTarget"/> is bound to.</returns>
public IRegion Initialize(T regionTarget, string regionName)
{
var page = regionTarget.GetParentPage();
var container = regionTarget.GetContainerProvider();
IRegion region = CreateRegion(container);
region.Name = regionName ?? throw new ArgumentNullException(nameof(regionName));
if (region is ITargetAwareRegion taRegion)
taRegion.TargetElement = regionTarget;
var children = page.GetChildRegions(true);
children.Add(region);
SetObservableRegionOnHostingControl(region, regionTarget);
Adapt(region, regionTarget);
AttachBehaviors(region, regionTarget);
AttachDefaultBehaviors(region, regionTarget);
return region;
}
/// <summary>
/// Adapts an object and binds it to a new <see cref="IRegion"/>.
/// </summary>
/// <param name="regionTarget">The object to adapt.</param>View on GitHub (pinned to 358118cd64)