{"record":{"id":"36e6cc346cdc283d","repo":"mono/mono","slug":"aot-of-image-s-failed","errorCode":null,"errorMessage":"AOT of image %s failed.\n","messagePattern":"AOT of image (.+?) failed\\.\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"mono/mini/driver.c","lineNumber":1447,"sourceCode":"\t\t\t\t} else {\n\t\t\t\t\tfprintf (stderr, \"Can not open image %s\\n\", main_args->argv [i]);\n\t\t\t\t\texit (1);\n\t\t\t\t}\n\t\t\t}\n\t\t\t/* Check that the assembly loaded matches the filename */\n\t\t\t{\n\t\t\t\tMonoImageOpenStatus status;\n\t\t\t\tMonoImage *img;\n\n\t\t\t\timg = mono_image_open (main_args->argv [i], &status);\n\t\t\t\tif (img && strcmp (img->name, assembly->image->name)) {\n\t\t\t\t\tfprintf (stderr, \"Error: Loaded assembly '%s' doesn't match original file name '%s'. Set MONO_PATH to the assembly's location.\\n\", assembly->image->name, img->name);\n\t\t\t\t\texit (1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tres = mono_compile_assembly (assembly, main_args->opts, main_args->aot_options, &aot_state);\n\t\t\tif (res != 0) {\n\t\t\t\tfprintf (stderr, \"AOT of image %s failed.\\n\", main_args->argv [i]);\n\t\t\t\texit (1);\n\t\t\t}\n\t\t}\n\t\tif (aot_state) {\n\t\t\tres = mono_compile_deferred_assemblies (main_args->opts, main_args->aot_options, &aot_state);\n\t\t\tif (res != 0) {\n\t\t\t\tfprintf (stderr, \"AOT of mode-specific deferred assemblies failed.\\n\");\n\t\t\t\texit (1);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tassembly = mono_domain_assembly_open_internal (main_args->domain, mono_domain_default_alc (main_args->domain), main_args->file);\n\t\tif (!assembly){\n\t\t\tfprintf (stderr, \"Can not open image %s\\n\", main_args->file);\n\t\t\texit (1);\n\t\t}\n\n\t\t/* ","sourceCodeStart":1429,"sourceCodeEnd":1465,"githubUrl":"https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/mini/driver.c#L1429-L1465","documentation":"In AOT mode, mono_compile_assembly returned non-zero for a specific assembly argument, meaning Ahead-Of-Time compilation of that image failed. The driver prints the offending path and exits(1). The root cause is inside the AOT compiler (LLVM/Mono backend, codegen, or signature/resolution errors) and is usually detailed by earlier stderr output.","triggerScenarios":"AOT-compiling an assembly that references types/members unavailable at AOT time, uses unsupported constructs for the target arch, fails LLVM lowering, or has a method the AOT compiler cannot process. mono_compile_assembly returns the failure code.","commonSituations":"Cross-AOT targeting a different arch without the right cross toolchain; AOT-ing an assembly that depends on P/Invoke or dynamic code; LLVM disabled/missing where the method requires it; version skew between framework assemblies and the one being compiled.","solutions":["Read the full stderr above this line: the AOT compiler prints the specific method/reason that failed.","For cross-compilation, install the correct target cross-toolchain and pass --llvm or the right mtriple (--aot=mtriple=...).","Exclude the failing assembly from the AOT batch, or AOT it separately with conservative flags (--aot=llvm-level=0, no-llvm).","Update Mono/framework assemblies to matching versions and retry."],"exampleFix":"# before\nmono --aot MyApp.dll   // mono_compile_assembly != 0\n# after: read the error above, then disable LLVM for that image\nmono --aot=llvm=false MyApp.dll","handlingStrategy":"retry","validationCode":"# Smoke-AOT a single image to surface the precise failure first\nmonodis --assembly \"$IMG\" >/dev/null 2>&1 || { echo \"bad image: $IMG\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["AOT images one at a time during debugging to get a clear per-image error.","Keep framework/dependency assemblies version-matched with the AOT target.","For cross-AOT, install the matching cross-toolchain and set mtriple."],"tags":["mono","aot","codegen","llvm","startup"],"backgroundTag":null,"analyzedSha":"0f53e9e151d92944cacab3e24ac359410c606df6","analyzedAt":"2026-08-13T18:54:37.190Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}