{"record":{"id":"fff0a6822b83d1a6","repo":"dotnet/runtime","slug":"no-assemblies-have-been-marked-as-lazy-loadable-u","errorCode":null,"errorMessage":"No assemblies have been marked as lazy-loadable. Use the 'BlazorWebAssemblyLazyLoad' item group in your project file to enable lazy loading an assembly.","messagePattern":"No assemblies have been marked as lazy-loadable\\. Use the 'BlazorWebAssemblyLazyLoad' item group in your project file to enable lazy loading an assembly\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/lazyLoading.ts","lineNumber":13,"sourceCode":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\nimport { loaderHelpers } from \"./globals\";\nimport { load_lazy_assembly } from \"./managed-exports\";\nimport { type AssemblyAsset, type PdbAsset } from \"./types\";\nimport { type AssetEntryInternal } from \"./types/internal\";\n\nexport async function loadLazyAssembly (assemblyNameToLoad: string): Promise<boolean> {\n    const resources = loaderHelpers.config.resources!;\n    const lazyAssemblies = resources.lazyAssembly;\n    if (!lazyAssemblies) {\n        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.\");\n    }\n\n    let assemblyNameWithoutExtension = assemblyNameToLoad;\n    if (assemblyNameToLoad.endsWith(\".dll\"))\n        assemblyNameWithoutExtension = assemblyNameToLoad.substring(0, assemblyNameToLoad.length - 4);\n    else if (assemblyNameToLoad.endsWith(\".wasm\"))\n        assemblyNameWithoutExtension = assemblyNameToLoad.substring(0, assemblyNameToLoad.length - 5);\n\n    const assemblyNameToLoadDll = assemblyNameWithoutExtension + \".dll\";\n    const assemblyNameToLoadWasm = assemblyNameWithoutExtension + \".wasm\";\n\n    let dllAsset: (AssemblyAsset & AssetEntryInternal) | null = null;\n    for (let i = 0; i < lazyAssemblies.length; i++) {\n        const asset = lazyAssemblies[i];\n        if (asset.virtualPath === assemblyNameToLoadDll || asset.virtualPath === assemblyNameToLoadWasm) {\n            dllAsset = asset as AssemblyAsset & AssetEntryInternal;\n            dllAsset.behavior = \"assembly\";\n            break;","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/lazyLoading.ts#L1-L31","documentation":"Thrown by loadLazyAssembly when loaderHelpers.config.resources.lazyAssembly is falsy. It means no assemblies were configured as lazy-loadable in the project, so there is nothing for the lazy loader to look up. This is a Blazor WebAssembly lazy-loading contract error.","triggerScenarios":"Produced when calling loadLazyAssembly (e.g. via Blazor's LazyAssemblyLoader or the underlying API) on an app whose boot config has no 'lazyAssembly' resource array — i.e. the project did not declare any <BlazorWebAssemblyLazyLoad> items.","commonSituations":"Calling LazyAssemblyLoader.LoadAssembliesAsync in a project that forgot to add the BlazorWebAssemblyLazyLoad item group; deploying the app without re-publishing after adding lazy-load references; the boot config (blazor.boot.json) lacks the lazyAssembly section.","solutions":["Add <BlazorWebAssemblyLazyLoad Include=\"YourAssembly.dll\" /> to the project's <ItemGroup> for each assembly you intend to load lazily.","Re-publish the app so blazor.boot.json includes the lazyAssembly resources.","Guard the LoadAssembliesAsync call so it only runs when lazy loading is actually configured."],"exampleFix":"<!-- before: calling lazy load with no configuration -->\n<!-- <ItemGroup> (nothing) </ItemGroup> -->\n\n<!-- after -->\n<ItemGroup>\n  <BlazorWebAssemblyLazyLoad Include=\"MyPlugin.dll\" />\n</ItemGroup>","handlingStrategy":"validation","validationCode":"// Check the boot config before calling lazy load\nconst lazy = dotnet.getConfig?.().resources?.lazyAssembly;\nif (!lazy || lazy.length === 0) {\n  // add <BlazorWebAssemblyLazyLoad> or skip the call\n}","typeGuard":"function hasLazyAssemblies(config: any): boolean {\n  return Array.isArray(config?.resources?.lazyAssembly) && config.resources.lazyAssembly.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Declare every assembly you lazy-load in <BlazorWebAssemblyLazyLoad>.","Republish after changing lazy-load items so blazor.boot.json stays in sync.","Gate LoadAssembliesAsync calls behind a config check."],"tags":["blazor","lazy-loading","assembly","config"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}