dotnet/runtime · error · Error
No assemblies have been marked as lazy-loadable. Use the…
Error message
No assemblies have been marked as lazy-loadable. Use the 'BlazorWebAssemblyLazyLoad' item group in your project file to enable lazy loading an assembly.
What it means
Thrown by fetchLazyAssembly() (src/native/libs/Common/JavaScript/loader/assets.ts:268). When managed code calls AssemblyLoadContext to lazily load an assembly at runtime, the loader looks up loaderConfig.resources.lazyAssembly; if that collection does not exist, no assembly was ever marked lazy-loadable, so it throws and tells you to use the BlazorWebAssemblyLazyLoad item group.
Solutions
- Add a <BlazorWebAssemblyLazyLoad Include="MyLazyAssembly.dll" /> item to the Blazor app project for each assembly you load lazily.
- If you no longer intend to lazy-load, remove the code path that calls LoadAssembliesAsync instead of leaving it dangling.
- Rebuild/re-publish after editing the item group so the boot config includes the lazyAssembly resource list.
Example fix
<!-- before: LoadAssembliesAsync called, no item group -> No assemblies have been marked as lazy-loadable --> <!-- after: add to the .csproj of the Blazor app --> <ItemGroup> <BlazorWebAssemblyLazyLoad Include="MyLazyAssembly.dll" /> </ItemGroup>
Defensive patterns
Strategy: validation
Validate before calling
function hasLazyAssemblies(resources: any): boolean {
return Array.isArray(resources?.lazyAssembly) && resources.lazyAssembly.length > 0;
}
if (!hasLazyAssemblies(loaderConfig.resources)) {
// do not call LazyAssemblyLoader.LoadAssembliesAsync, or add the item group
} Type guard
function hasLazyLoadables(r: any): r is { lazyAssembly: { virtualPath: string }[] } {
return Array.isArray(r?.lazyAssembly) && r.lazyAssembly.length > 0;
} Prevention
- Add <BlazorWebAssemblyLazyLoad Include="...dll" /> for every assembly you load lazily.
- Re-publish after editing the item group so lazyAssembly is present in the boot config.
- Remove dangling LoadAssembliesAsync call sites if lazy loading is no longer used.
When it happens
Trigger: Managed code triggers a lazy assembly load (e.g. NavigationManager for a page whose component assembly is lazy, or an explicit AssemblyLoadContext.Load). fetchLazyAssembly is invoked; resources.lazyAssembly is undefined, so line 270 throws.
Common situations: Calling LazyAssemblyLoader.LoadAssembliesAsync without having marked any assembly with BlazorWebAssemblyLazyLoad in the project; removing the item group but keeping the lazy-load call site; a route to a lazy component without registering its assembly as lazy-loadable.
Related errors
- must be marked with 'BlazorWebAssemblyLazyLoad' item group…
- must be marked with 'BlazorWebAssemblyLazyLoad' item group…
- No assemblies have been marked as lazy-loadable. Use the…
- Can't use moduleFactory callback of createDotnetRuntime…
- Cannot call synchronous C# methods.
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/25d1ef81839d3450.
Report an issue: GitHub.
Appendix: source
Thrown at src/native/libs/Common/JavaScript/loader/assets.ts:271
continue;
}
for (const asset of satelliteResources[culture]) {
const assetInternal = asset as AssetEntryInternal;
assetInternal.culture = culture;
promises.push(fetchAssembly(asset));
}
}
await Promise.all(promises);
}
function lazyAssetFileName(virtualPath: string): string {
return virtualPath.substring(virtualPath.lastIndexOf("/") + 1);
}
export async function fetchLazyAssembly(assemblyNameToLoad: string): Promise<boolean> {
const lazyAssemblies = loaderConfig.resources?.lazyAssembly;
if (!lazyAssemblies) {
throw new Error("No assemblies have been marked as lazy-loadable. Use the 'BlazorWebAssemblyLazyLoad' item group in your project file to enable lazy loading an assembly.");
}
let assemblyNameWithoutExtension = assemblyNameToLoad;
if (assemblyNameToLoad.endsWith(".dll"))
assemblyNameWithoutExtension = assemblyNameToLoad.substring(0, assemblyNameToLoad.length - 4);
else if (assemblyNameToLoad.endsWith(".wasm"))
assemblyNameWithoutExtension = assemblyNameToLoad.substring(0, assemblyNameToLoad.length - 5);
if (loadedLazyAssemblies.has(assemblyNameWithoutExtension)) {
return false;
}
const assemblyNameToLoadDll = assemblyNameWithoutExtension + ".dll";
const assemblyNameToLoadWasm = assemblyNameWithoutExtension + ".wasm";
let dllAsset: AssemblyAsset | null = null;
for (const asset of lazyAssemblies) {
const fileName = lazyAssetFileName(asset.virtualPath);View on GitHub (pinned to 60108ba66e)