{"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/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/hosts/corerun/corerun.cpp#L621-L657","documentation":"Opening marker printed when coreclr_execute_assembly() returns a failing HRESULT inside run(). It brackets the logger.dump_details() output before the END line at 641. By this point CoreCLR initialized successfully; the failure is in loading/running the entry assembly itself (e.g. missing dependency, bad image, unhandled managed exception at startup).","triggerScenarios":"coreclr_execute_func() is called with CurrentClrInstance, CurrentAppDomainId, argc, argv (UTF-8), entry_assembly path. It fails — common causes: assembly not found, FileLoadException-level failures, BadImageFormatException, missing dependency on the TPA list / APP_PATHS, or a security/CLR policy rejection.","commonSituations":"Entry assembly references a DLL not present in TRUSTED_PLATFORM_ASSEMBLIES or APP_PATHS; assembly compiled against a different target framework; mixed 32/64 bit assembly loaded into a runtime of the wrong bitness; corrupted PE file.","solutions":["Decode the HRESULT (e.g. 0x80070002 missing file, 0x80131522 BadImageFormat).","Inspect the dumped 'Managed assembly' and 'APP_PATHS'/'NATIVE_DLL_SEARCH_DIRECTORIES' to confirm dependencies resolve.","Ensure all referenced assemblies are either on the TPA list, in the app directory, or resolvable via the external assembly probe.","Rebuild the entry assembly against the same .NET target framework the loaded CoreCLR provides.","If using APP_ASSEMBLIES=EXTERNAL, verify the external_assembly_probe callbacks can find the file under s_core_libs_path / s_core_root_path."],"exampleFix":"# before: dependency not on the TPA list\ncorerun App.dll  # App references Newtonsoft.Json.dll not in CORE_ROOT\n# after: add the lib dir to native search / TPA\nexport CORE_LIBRARIES=/app/libs\ncorerun App.dll","handlingStrategy":"validation","validationCode":"# before running, verify the entry assembly and its obvious deps exist\ntest -f \"$ASSEMBLY\" || { echo \"missing entry assembly: $ASSEMBLY\"; exit 1; }\n# list referenced assemblies and check they resolve against CORE_ROOT/CORE_LIBRARIES\nfor d in $(dirname \"$ASSEMBLY\") \"$CORE_ROOT\" \"${CORE_LIBRARIES:-}\"; do\n  [ -n \"$d\" ] && [ -d \"$d\" ] && echo \"probe dir: $d\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Place all dependency DLLs in the app directory or a dir on NATIVE_DLL_SEARCH_DIRECTORIES.","Ensure the entry assembly targets the framework version the loaded CoreCLR provides.","Match bitness between the assembly and the runtime.","Decode the HRESULT to narrow down BadImageFormat vs FileNotFound."],"tags":["coreclr","corerun","runtime-host","assembly-load","hresult"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}