dotnet/aspnetcore · error · InvalidOperationException
The {nameof(Router)} component requires a value for the para
Error message
The {nameof(Router)} component requires a value for the parameter {nameof(AppAssembly)}. What it means
The Router component requires AppAssembly (or AdditionalAssemblies) to know where to scan for [Route]-attributed page components. SetParametersAsync throws InvalidOperationException if AppAssembly is null on first parameter set, because without an assembly there is no route table to consult. The check runs before any rendering so the misconfiguration fails fast.
Source
Thrown at src/Components/Components/src/Routing/Router.cs:127
_locationAbsolute = NavigationManager.Uri;
NavigationManager.LocationChanged += OnLocationChanged;
NavigationManager.OnNotFound += OnNotFound;
RoutingStateProvider = ServiceProvider.GetService<IRoutingStateProvider>();
if (HotReloadManager.IsSupported)
{
HotReloadManager.Default.OnDeltaApplied += ClearRouteCaches;
}
}
/// <inheritdoc />
public async Task SetParametersAsync(ParameterView parameters)
{
parameters.SetParameterProperties(this);
if (AppAssembly == null)
{
throw new InvalidOperationException($"The {nameof(Router)} component requires a value for the parameter {nameof(AppAssembly)}.");
}
// Found content is mandatory, because even though we could use something like <RouteView ...> as a
// reasonable default, if it's not declared explicitly in the template then people will have no way
// to discover how to customize this (e.g., to add authorization).
if (Found == null)
{
throw new InvalidOperationException($"The {nameof(Router)} component requires a value for the parameter {nameof(Found)}.");
}
if (NotFoundPage != null)
{
#pragma warning disable CS0618 // Type or member is obsolete
if (NotFound != null)
{
throw new InvalidOperationException($"Setting {nameof(NotFound)} and {nameof(NotFoundPage)} properties simultaneously is not supported. Use either {nameof(NotFound)} or {nameof(NotFoundPage)}.");
}
#pragma warning restore CS0618 // Type or member is obsoleteView on GitHub (pinned to 3600ca084e)
Solutions
- Set AppAssembly on the Router, typically AppAssembly="@typeof(Program).Assembly" or @typeof(SomeType).Assembly.
- If your pages live in multiple assemblies, also set AdditionalAssemblies with the full list.
- Verify the typeof target compiles and the assembly it points to actually contains your @page components.
- Add an integration test that renders App.razor to catch missing AppAssembly early.
Example fix
// before (App.razor)
<Router>
<Found Context="routeData"><RouteView RouteData="@routeData" /></Found>
</Router>
// after
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData"><RouteView RouteData="@routeData" /></Found>
</Router> Defensive patterns
Strategy: validation
Validate before calling
// In App.razor, always supply AppAssembly. Validate at startup:
var asm = typeof(Program).Assembly;
if (asm is null) throw new InvalidOperationException("Program assembly not resolvable."); Prevention
- Use the standard scaffolded App.razor with AppAssembly="@typeof(Program).Assembly".
- If pages live in other assemblies, also set AdditionalAssemblies.
- Add an integration test that renders the root component to catch missing parameters early.
- Keep App.razor under code review when refactoring routing.
When it happens
Trigger: Declaring <Router>...</Router> without an AppAssembly attribute, or binding AppAssembly to an expression that resolves to null (e.g. a static that has not been initialized). Also triggered by manually constructing Router and calling SetParametersAsync without AppAssembly.
Common situations: Starting a new Blazor project and editing App.razor without setting AppAssembly; renaming the assembly and forgetting to update @inject or the typeof expression; refactoring the Router markup and dropping the attribute; binding to a property that is conditionally initialized.
Related errors
- The {nameof(Router)} component requires a value for the para
- Setting {nameof(NotFound)} and {nameof(NotFoundPage)} proper
- The type {NotFoundPage.FullName} does not implement {typeof(
- The type {NotFoundPage.FullName} does not have a {typeof(Rou
- The type {context.Handler.FullName} does not implement {type
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/66a13869e0852260.
Report an issue: GitHub.