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

  1. Re-publish the app so blazor.boot.json / the runtime config is complete.
  2. If configuring the runtime programmatically, ensure the config object includes resources.assembly, resources.coreAssembly, mainAssemblyName, virtualWorkingDirectory, and environmentVariables.
  3. 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

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


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)