dotnet/runtime · critical · Error
Invalid runtime config, cannot initialize the runtime.
Error message
Invalid runtime config, cannot initialize the runtime.
What it means
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.
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.
Example fix
// before: config missing virtualWorkingDirectory -> Invalid runtime config
const config = { /* ... */ };
// after
const config = {
/* ... */
virtualWorkingDirectory: '/',
environmentVariables: {},
resources: { assembly: [...], coreAssembly: [...] },
mainAssemblyName: 'MyApp.dll',
}; Defensive patterns
Strategy: validation
Validate before calling
function isValidRuntimeConfig(c: any): boolean {
return !!(c?.resources?.assembly && c.resources.coreAssembly?.length
&& c.mainAssemblyName && c.virtualWorkingDirectory && c.environmentVariables);
} Type guard
function isCompleteConfig(c: any): c is { resources: { assembly: unknown[]; coreAssembly: unknown[] }; mainAssemblyName: string; virtualWorkingDirectory: string; environmentVariables: Record<string,string> } {
return !!(c?.resources?.assembly && c.resources.coreAssembly?.length
&& c.mainAssemblyName && c.virtualWorkingDirectory && c.environmentVariables);
} Prevention
- 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.
When it happens
Trigger: dotnetInitializeModule() calls setupEmscripten(); getConfig() returns LoaderConfigInternal. Any of the required fields being absent/empty trips the guard at lines 55-61.
Common situations: 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.
Related errors
- Invalid config, resources is not set
- Webcil asset ' ' is missing payloadSize in the boot config.
- must be marked with 'BlazorWebAssemblyLazyLoad' item group…
- must be marked with 'BlazorWebAssemblyLazyLoad' item group…
- Can't use moduleFactory callback of createDotnetRuntime…
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/c03e0ca88ae3e6fa.
Report an issue: GitHub.
Appendix: source
Thrown at src/native/libs/Common/JavaScript/host/index.ts:62
map.loadIcuData,
map.initializeCoreCLR,
map.registerPdbBytes,
map.instantiateWasm,
map.instantiateWebcilModule,
];
}
}
function setupEmscripten() {
const loaderConfig = _ems_.dotnetApi.getConfig() as LoaderConfigInternal;
if (!loaderConfig.resources ||
!loaderConfig.resources.assembly ||
!loaderConfig.resources.coreAssembly ||
loaderConfig.resources.coreAssembly.length === 0 ||
!loaderConfig.mainAssemblyName ||
!loaderConfig.virtualWorkingDirectory ||
!loaderConfig.environmentVariables) {
throw new Error("Invalid runtime config, cannot initialize the runtime.");
}
for (const key in loaderConfig.environmentVariables) {
_ems_.ENV[key] = loaderConfig.environmentVariables[key];
}
}
export { BrowserHost_ExternalAssemblyProbe } from "./assets";
View on GitHub (pinned to 60108ba66e)