PrismLibrary/Prism · error · ArgumentException
The region name cannot be null or empty.
Error message
The region name cannot be null or empty.
What it means
Setting Region.Name to null or empty throws ArgumentException (Resources.RegionNameCannotBeEmptyException). The name is the key under which the RegionManager indexes regions, and an empty key would make the region unreachable. Distinct from error 106, which covers renaming; this covers first-time assignment of an invalid value.
Solutions
- Supply a non-empty name when creating the region: new Region { Name = "ContentRegion" }.
- Validate the name string in the region adapter before assigning.
- Ensure the underlying control/element name used to derive the region name is set.
Example fix
// before
var region = new Region { Name = control.Name }; // may be empty
// after
var regionName = !string.IsNullOrEmpty(control.Name) ? control.Name : "ContentRegion";
var region = new Region { Name = regionName }; Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(name))
throw new ArgumentException("Region name must be non-empty");
var region = new Region { Name = name }; Type guard
bool IsValidRegionName(string n) => !string.IsNullOrEmpty(n);
Try / catch
try
{
region.Name = name;
}
catch (ArgumentException)
{
// fall back to a default region name
} Prevention
- Validate the source of the name (control.Name, config) before assignment.
- Use nameof(...) or constants for region names.
- Check region adapter logic for empty derived names.
When it happens
Trigger: region.Name = null; region.Name = ""; or a custom region adapter computing the region name from a null/empty string (e.g. a Control whose Name is not set).
Common situations: Region adapters deriving names from XAML element names that are missing; dynamic region creation where the name variable is empty; data-bound region name that failed to resolve.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- The provided String argument
- Resources.RegionNameCannotBeEmptyException
- Invalid Tab Name
- Cannot change the region name once is set. The current…
- The method or operation is not implemented.
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/ac0ed68efdc3a73e.
Report an issue: GitHub.
Appendix: source
Thrown at src/Maui/Prism.Maui/Navigation/Regions/Region.cs:111
private string _name;
/// <summary>
/// Gets the name of the region that uniquely identifies the region within a <see cref="IRegionManager"/>.
/// </summary>
/// <value>The name of the region.</value>
public string Name
{
get => _name;
set
{
if (_name != null && _name != value)
{
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.CannotChangeRegionNameException, _name));
}
if (string.IsNullOrEmpty(value))
{
throw new ArgumentException(Resources.RegionNameCannotBeEmptyException);
}
_name = value;
RaisePropertyChanged(nameof(Name));
}
}
/// <summary>
/// Gets or sets the comparison used to sort the views.
/// </summary>
/// <value>The comparison to use.</value>
public Comparison<object> SortComparison
{
get => _sort;
set
{
_sort = value;
View on GitHub (pinned to 358118cd64)