OrchardCMS/OrchardCore · critical · ApplicationException
Fatal error, a Layout couldn't be created.
Error message
Fatal error, a Layout couldn't be created.
What it means
LayoutAccessor.GetLayoutInternalAsync builds the Layout shape and casts it to IZoneHolding. If the created layout is null — the shape factory produced no Layout shape, which should never happen in a correctly configured site — it throws ApplicationException("Fatal error, a Layout couldn't be created."). This is an internal invariant guard during page rendering.
Solutions
- Enable a theme that provides a Layout shape (e.g., via admin or by fixing the tenant's current theme setting).
- Fix the underlying shape creation failure — check logs for the earlier exception (often a null shape factory result for 'Layout').
- Verify IShapeFactory and display infrastructure are correctly registered and the request is running inside a tenant shell scope, not root.
Example fix
// before (tenant settings) "CurrentTheme": "MyBrokenTheme" // after — re-enable a working theme services.TryAddScoped<IThemeSelector, DefaultThemeSelector>(); // or reset theme in admin: Themes -> set 'TheTheme'
Defensive patterns
Strategy: try-catch
Try / catch
catch (ApplicationException ex) when (ex.Message.Contains("Layout couldn't be created"))
{
logger.LogCritical(ex, "Layout shape missing; check active theme and shape factory");
throw; // rendering cannot continue without a layout
} Prevention
- Always keep at least one functional theme enabled on every tenant
- Check startup logs for earlier shape/DI errors that cascade into layout failure
- After theme changes, smoke-test a page render in staging
- Run tenant requests inside a proper shell scope in custom middleware
When it happens
Trigger: Requesting the layout (GetLayoutAsync) on a tenant where the 'Layout' shape cannot be created — e.g., the theme's layout binding/factory missing, shape creation returning null, or theme modules disabled.
Common situations: Broken or partially disabled theme that no longer defines the Layout shape; errors earlier in shape creation (see DefaultShapeFactory null creation); recipes/themes switched so no active theme provides a layout; startup DI failures swallowed earlier.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- The shape type ' ' is not found for the theme
- Zone not found:
- Zone not found:
- Shape creation failed for type
- DisplayAsync requires an instance of IShape
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/b118ed2b935e2909.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.DisplayManagement/Layout/LayoutAccessor.cs:47
return GetLayoutInternalAsync();
}
private async Task<IZoneHolding> GetLayoutInternalAsync()
{
// Create a shape whose properties are dynamically created as Zone shapes.
var layout = await _shapeFactory.CreateAsync(
"Layout",
static (shapeFactory) =>
ValueTask.FromResult<IShape>(
new ZoneHolding<IShapeFactory>(
static (factory) => factory.CreateAsync("Zone"),
shapeFactory)),
_shapeFactory) as IZoneHolding;
if (layout == null)
{
// At this point a Layout shape should always exist.
throw new ApplicationException("Fatal error, a Layout couldn't be created.");
}
_layout = Task.FromResult(layout);
return layout;
}
}
View on GitHub (pinned to 4306c0717f)