{"record":{"id":"c03e0ca88ae3e6fa","repo":"dotnet/runtime","slug":"invalid-runtime-config-cannot-initialize-the-runt","errorCode":null,"errorMessage":"Invalid runtime config, cannot initialize the runtime.","messagePattern":"Invalid runtime config, cannot initialize the runtime\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/native/libs/Common/JavaScript/host/index.ts","lineNumber":62,"sourceCode":"            map.loadIcuData,\n            map.initializeCoreCLR,\n            map.registerPdbBytes,\n            map.instantiateWasm,\n            map.instantiateWebcilModule,\n        ];\n    }\n}\n\nfunction setupEmscripten() {\n    const loaderConfig = _ems_.dotnetApi.getConfig() as LoaderConfigInternal;\n    if (!loaderConfig.resources ||\n        !loaderConfig.resources.assembly ||\n        !loaderConfig.resources.coreAssembly ||\n        loaderConfig.resources.coreAssembly.length === 0 ||\n        !loaderConfig.mainAssemblyName ||\n        !loaderConfig.virtualWorkingDirectory ||\n        !loaderConfig.environmentVariables) {\n        throw new Error(\"Invalid runtime config, cannot initialize the runtime.\");\n    }\n\n    for (const key in loaderConfig.environmentVariables) {\n        _ems_.ENV[key] = loaderConfig.environmentVariables[key];\n    }\n}\n\nexport { BrowserHost_ExternalAssemblyProbe } from \"./assets\";\n","sourceCodeStart":44,"sourceCodeEnd":71,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/Common/JavaScript/host/index.ts#L44-L71","documentation":"Thrown by setupEmscripten when the loader config is missing required fields: resources, resources.assembly, resources.coreAssembly (non-empty), mainAssemblyName, virtualWorkingDirectory, and environmentVariables. These are normally generated by MSBuild into the runtime config; absence means the runtime cannot locate its assemblies or working directory.","triggerScenarios":"dotnet.create() / runtime bootstrap where the MonoWasmRuntimeConfig (embedded in index.html or fetched JSON) is incomplete or hand-edited so any required field is undefined/empty.","commonSituations":"Manually editing index.html and stripping config; broken publish; pointing the loader at a config from a different project type; empty resources.coreAssembly because no assemblies were included.","solutions":["Regenerate index.html and the runtime config via dotnet publish instead of hand-editing.","Confirm the config JSON has resources.coreAssembly with at least one entry and a non-empty mainAssemblyName.","Set virtualWorkingDirectory and environmentVariables in the loader options or generated config.","Match the loader API version to the generated config schema of this SDK."],"exampleFix":"// before: dotnet.create() with a stripped config object\ndotnet.create({ resources: { assembly: [] } });\n// after: pass the full generated config\ndotnet.create(loadedRuntimeConfig); // has resources.coreAssembly, mainAssemblyName, etc.","handlingStrategy":"validation","validationCode":"// Validate the generated config shape before creating the runtime\nfunction isValidRuntimeConfig(c) {\n  return !!(c?.resources?.assembly &&\n           c.resources.coreAssembly?.length &&\n           c.mainAssemblyName &&\n           c.virtualWorkingDirectory &&\n           c.environmentVariables);\n}\nif (!isValidRuntimeConfig(config)) {\n  throw new Error('Runtime config is incomplete; regenerate via dotnet publish.');\n}\nawait dotnet.create(config);","typeGuard":"function isLoaderConfigInternal(c): c is LoaderConfigInternal {\n  return !!c\n    && typeof c === 'object'\n    && !!c.resources?.assembly\n    && Array.isArray(c.resources?.coreAssembly) && c.resources.coreAssembly.length > 0\n    && typeof c.mainAssemblyName === 'string'\n    && typeof c.virtualWorkingDirectory === 'string'\n    && typeof c.environmentVariables === 'object';\n}","tryCatchPattern":null,"preventionTips":["Never hand-edit the generated runtime config; regenerate it with MSBuild.","Assert the config has coreAssembly + mainAssemblyName in dev before boot.","Keep the loader API version aligned with the config schema of the same SDK."],"tags":["configuration","initialization","wasm","validation"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}