{"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":"exception","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/60108ba66eb7d1d12f595480091b4ad80a24b172/src/native/libs/Common/JavaScript/host/index.ts#L44-L71","documentation":"Thrown by setupEmscripten() (src/native/libs/Common/JavaScript/host/index.ts:53) during initialization. It reads the loader config and asserts that resources, resources.assembly, resources.coreAssembly (non-empty), mainAssemblyName, virtualWorkingDirectory, and environmentVariables are all present. If any is missing the runtime cannot bootstrap, so it throws.","triggerScenarios":"dotnetInitializeModule() calls setupEmscripten(); getConfig() returns LoaderConfigInternal. Any of the required fields being absent/empty trips the guard at lines 55-61.","commonSituations":"A hand-crafted or truncated runtime config; a custom config loader that omitted one of the required sections; a publish that produced an incomplete blazor.boot.json; a loadBootResourceCallback that replaced the config response with a partial object.","solutions":["Re-publish the app so blazor.boot.json / the runtime config is complete.","If configuring the runtime programmatically, ensure the config object includes resources.assembly, resources.coreAssembly, mainAssemblyName, virtualWorkingDirectory, and environmentVariables.","Inspect the actual config object passed to the runtime (log getConfig()) and fill the missing field."],"exampleFix":"// before: config missing virtualWorkingDirectory -> Invalid runtime config\nconst config = { /* ... */ };\n\n// after\nconst config = {\n  /* ... */\n  virtualWorkingDirectory: '/',\n  environmentVariables: {},\n  resources: { assembly: [...], coreAssembly: [...] },\n  mainAssemblyName: 'MyApp.dll',\n};","handlingStrategy":"validation","validationCode":"function isValidRuntimeConfig(c: any): boolean {\n  return !!(c?.resources?.assembly && c.resources.coreAssembly?.length\n    && c.mainAssemblyName && c.virtualWorkingDirectory && c.environmentVariables);\n}","typeGuard":"function isCompleteConfig(c: any): c is { resources: { assembly: unknown[]; coreAssembly: unknown[] }; mainAssemblyName: string; virtualWorkingDirectory: string; environmentVariables: Record<string,string> } {\n  return !!(c?.resources?.assembly && c.resources.coreAssembly?.length\n    && c.mainAssemblyName && c.virtualWorkingDirectory && c.environmentVariables);\n}","tryCatchPattern":null,"preventionTips":["Always obtain the runtime config via the SDK publish output rather than hand-authoring it.","Validate the config shape in a custom loader before passing it to create().","Do not let a custom loadBootResourceCallback return a partial config object."],"tags":["configuration","boot-config","initialization"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}