dotnet/maui · error · InvalidOperationException
Content not found for active {ShellSection}. Title: {ShellSe
Error message
Content not found for active {ShellSection}. Title: {ShellSection.Title}. Route: {ShellSection.Route}. What it means
Thrown by the iOS ShellSectionRootRenderer.ViewDidLoad when ShellSection.CurrentItem is null. The ShellSectionRootRenderer is the UIViewController for a ShellSection's root content on iOS. ViewDidLoad is called once when the view controller's view is first loaded; if the ShellSection has no active ShellContent at that point, the renderer cannot build its content area.
Source
Thrown at src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRootRenderer.cs:111
{
base.TraitCollectionDidChange(previousTraitCollection);
if (previousTraitCollection?.VerticalSizeClass != TraitCollection.VerticalSizeClass ||
previousTraitCollection?.HorizontalSizeClass != TraitCollection.HorizontalSizeClass)
{
if (OperatingSystem.IsIOSVersionAtLeast(26) || OperatingSystem.IsMacCatalystVersionAtLeast(26))
{
(_tracker as ShellPageRendererTracker)?.UpdateTitleViewFrameForOrientation();
}
}
}
public override void ViewDidLoad()
{
if (_isDisposed)
return;
if (ShellSection.CurrentItem == null)
throw new InvalidOperationException($"Content not found for active {ShellSection}. Title: {ShellSection.Title}. Route: {ShellSection.Route}.");
base.ViewDidLoad();
_containerArea = new UIView();
if (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsMacCatalystVersionAtLeast(11)
#if TVOS
|| OperatingSystem.IsTvOSVersionAtLeast(11)
#endif
)
{
_containerArea.InsetsLayoutMarginsFromSafeArea = false;
}
View.AddSubview(_containerArea);
LoadRenderers();
ShellSection.PropertyChanged += OnShellSectionPropertyChanged;View on GitHub (pinned to f377ff1c5e)
Solutions
- Ensure every ShellSection has at least one ShellContent child before its view controller loads.
- When creating sections dynamically, add ShellContent and set CurrentItem before navigation.
- Verify XAML structure: ShellSection must contain ShellContent with valid Content/ContentTemplate.
- Use the Title/Route from the error to locate the specific ShellSection.
- Avoid removing the active ShellContent while the section is visible — switch CurrentItem first.
Example fix
// before
var section = new ShellSection { Title = "Browse", Route = "browse" };
item.Items.Add(section);
// no ShellContent — ViewDidLoad will throw
// after
var section = new ShellSection { Title = "Browse", Route = "browse" };
section.Items.Add(new ShellContent
{
ContentTemplate = new DataTemplate(() => new BrowsePage()),
Route = "browsecontent"
});
item.Items.Add(section); Defensive patterns
Strategy: validation
Validate before calling
// Verify ShellSection has content before ViewDidLoad fires
if (shellSection.CurrentItem == null)
throw new InvalidOperationException($"ShellSection '{shellSection.Title}' has no content."); Type guard
public static bool ShellSectionHasContent(ShellSection section)
=> section?.CurrentItem != null; Prevention
- Ensure ShellSection has at least one ShellContent before its view controller loads.
- Add ShellContent in the constructor or OnInitialized, not after display.
- Avoid removing the active ShellContent from a visible ShellSection.
When it happens
Trigger: At line 111: `if (ShellSection.CurrentItem == null) throw`. ViewDidLoad is a UIKit lifecycle method. Triggered when: (1) the ShellSection has no ShellContent children; (2) CurrentItem was nulled or not set; (3) the view controller was loaded before content was assigned (timing issue); (4) ShellContent was removed during the section's lifecycle.
Common situations: 1) ShellSection defined without ShellContent children in XAML. 2) Dynamic removal of ShellContent while the section's view controller is loading. 3) Route-based navigation that lands on an empty ShellSection. 4) ShellSection created programmatically without adding content. 5) Lifecycle timing where ViewDidLoad fires before ShellSection is fully configured.
Related errors
- Content not found for active {ShellItem}. Title: {ShellItem.
- Reuse of the Shell Renderer is not supported
- Active Shell Item not set. Have you added any Shell Items to
- Content not found for active {Shell.CurrentItem}. Title: {Sh
- view
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/e9195c99c69e6912.
Report an issue: GitHub.