dotnet/runtime · error · Error

No assemblies have been marked as lazy-loadable. Use the 'Bl

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

fetchLazyAssembly throws this when loaderConfig.resources.lazyAssembly is falsy. Lazy loading (Blazor WebAssembly) requires the project to declare <BlazorWebAssemblyLazyLoad Include="..." /> entries; those populate resources.lazyAssembly in the boot config. Without any, the runtime cannot satisfy a lazy load request.

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 290d5ab72c)

Solutions

  1. Add <BlazorWebAssemblyLazyLoad Include="MyLazy" /> to the .csproj of the Blazor WebAssembly project.
  2. Republish so blazor.boot.json lists the assembly under lazyAssembly.
  3. If you did not intend to lazy load, remove the runtime call that triggers fetchLazyAssembly.
  4. Confirm the published boot config actually contains a lazyAssembly array (inspect blazor.boot.json).

Example fix

<!-- before -->
<ItemGroup>
  <BlazorWebAssemblyLazyLoad Include="" />
</ItemGroup>

<!-- after -->
<ItemGroup>
  <BlazorWebAssemblyLazyLoad Include="MyLazy" />
  <BlazorWebAssemblyLazyLoad Include="PluginLib" />
</ItemGroup>
Defensive patterns

Strategy: type-guard

Validate before calling

if (!Array.isArray(getLoaderConfig().resources?.lazyAssembly) || getLoaderConfig().resources.lazyAssembly.length === 0) {
  console.warn('Lazy load requested but no <BlazorWebAssemblyLazyLoad> declared — add items to .csproj');
}

Type guard

function hasLazyAssemblies(cfg: any): boolean {
  return Array.isArray(cfg?.resources?.lazyAssembly) && cfg.resources.lazyAssembly.length > 0;
}

Try / catch

try { await loadLazyAssembly(name); }
catch (err) {
  if (/No assemblies have been marked as lazy-loadable/.test(err.message)) {
    // feature not configured — fall back to eager or skip
  } else throw err;
}

Prevention

When it happens

Trigger: Application code calls the Blazor lazy-load API (e.g. await JS.Import('MyLazy.dll') / WebAssemblyLoadAssembly) but no <BlazorWebAssemblyLazyLoad> items were declared in the .csproj, so resources.lazyAssembly is undefined.

Common situations: Developer added lazy-loading call site but forgot to register the assembly in the project file; the <BlazorWebAssemblyLazyLoad> item was removed during a refactor; running against an old boot config generated before the items were added.

Related errors


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/25d1ef81839d3450. Report an issue: GitHub.