{"record":{"id":"fcb96bfebc5f370a","repo":"dotnet/runtime","slug":"begin-coreclr-execute-assembly-failed-error-0x","errorCode":null,"errorMessage":"BEGIN: coreclr_execute_assembly failed - Error: 0x%08x\n","messagePattern":"BEGIN: coreclr_execute_assembly failed - Error: 0x%08x\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/coreclr/hosts/corerun/corerun.cpp","lineNumber":639,"sourceCode":"    if (coreclr_set_error_writer_func != nullptr)\n    {\n        coreclr_set_error_writer_func(nullptr);\n    }\n\n    int exit_code;\n    {\n        actions.before_execute_assembly(config.entry_assembly_fullpath);\n\n        result = coreclr_execute_func(\n            CurrentClrInstance,\n            CurrentAppDomainId,\n            config.entry_assembly_argc,\n            argv_utf8.get(),\n            entry_assembly_utf8.c_str(),\n            (uint32_t*)&exit_code);\n        if (FAILED(result))\n        {\n            pal::fprintf(stderr, W(\"BEGIN: coreclr_execute_assembly failed - Error: 0x%08x\\n\"), result);\n            logger.dump_details();\n            pal::fprintf(stderr, W(\"END: coreclr_execute_assembly failed - Error: 0x%08x\\n\"), result);\n            return -1;\n        }\n\n        actions.after_execute_assembly();\n    }\n\n#ifdef TARGET_BROWSER\n    // in NodeJS/Browser this is not really end of the process, JS keeps running.\n    // We want to keep the CoreCLR runtime alive to be able to process async work\n    // The NodeJS process is kept alive by pending async work via safeSetTimeout() -> runtimeKeepalivePush()\n    // The actual exit code would be set by SystemJS_ResolveMainPromise if the managed Main() is async.\n    // Or in Module.onExit handler when  managed Main() is synchronous.\n    return exit_code;\n#else // TARGET_BROWSER\n    int final_exit_code = corerun_shutdown(exit_code);\n#ifdef TARGET_WASI","sourceCodeStart":621,"sourceCodeEnd":657,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/hosts/corerun/corerun.cpp#L621-L657","documentation":"Printed by corerun when coreclr_execute_assembly fails to run the managed entry assembly at src/coreclr/hosts/corerun/corerun.cpp:639. Unlike initialization, by this point the runtime is up; failure usually means the assembly path is invalid, the assembly is not a valid managed PE, or the managed entry point threw during early binding/resolution.","triggerScenarios":"Emitted after coreclr_execute_func returns a FAILED HRESULT. Common causes: entry_assembly_fullpath does not exist or is not a valid .NET assembly, the assembly lacks an entry point, AppDomain assembly resolution fails for a dependency, or the target framework is incompatible with the loaded runtime.","commonSituations":"Pointing corerun at a native DLL or a .NET Framework assembly while running on CoreCLR, missing a dependency that the assembly references, or a corrupt/truncated assembly file.","solutions":["Confirm the file passed to corerun exists and is a valid managed assembly (run ildasm/dotdump or `file` on it).","Ensure all dependencies are resolvable (place them beside the assembly or set APP_PATHS / TRUSTED_PLATFORM_ASSEMBLIES correctly).","Decode the HRESULT to distinguish FileNotFound/FileLoad from execution-engine failures.","Rebuild the assembly against the same target framework as the loaded runtime."],"exampleFix":"// before\ncorerun -c /runtimes/unix MyLib.dll\n// after\ncorerun -c /runtimes/unix MyApp.dll  # an app with an entry point","handlingStrategy":"validation","validationCode":"// Validate the entry assembly before passing it to corerun\n#include <filesystem>\nnamespace fs = std::filesystem;\nbool entry_ok(const fs::path& asm_path) {\n    if (!fs::exists(asm_path)) return false;\n    // Read DOS+PE header to confirm it is a .NET assembly\n    std::ifstream f(asm_path, std::ios::binary);\n    unsigned char hdr[0x80];\n    f.read(reinterpret_cast<char*>(hdr), sizeof(hdr));\n    return hdr[0]==0x4D && hdr[1]==0x5A; // 'MZ'\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the entry assembly is a valid managed PE before running.","Place dependencies next to the assembly or in TRUSTED_PLATFORM_ASSEMBLIES.","Build the assembly against the same target framework as the loaded runtime.","Decode the HRESULT to distinguish load failures from execution failures."],"tags":["coreclr","corerun","assembly-execution","host"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}