mono/mono · critical
AOT of image %s failed.
Error message
AOT of image %s failed.
What it means
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.
Source
Thrown at mono/mini/driver.c:1447
} else {
fprintf (stderr, "Can not open image %s\n", main_args->argv [i]);
exit (1);
}
}
/* Check that the assembly loaded matches the filename */
{
MonoImageOpenStatus status;
MonoImage *img;
img = mono_image_open (main_args->argv [i], &status);
if (img && strcmp (img->name, assembly->image->name)) {
fprintf (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);
exit (1);
}
}
res = mono_compile_assembly (assembly, main_args->opts, main_args->aot_options, &aot_state);
if (res != 0) {
fprintf (stderr, "AOT of image %s failed.\n", main_args->argv [i]);
exit (1);
}
}
if (aot_state) {
res = mono_compile_deferred_assemblies (main_args->opts, main_args->aot_options, &aot_state);
if (res != 0) {
fprintf (stderr, "AOT of mode-specific deferred assemblies failed.\n");
exit (1);
}
}
} else {
assembly = mono_domain_assembly_open_internal (main_args->domain, mono_domain_default_alc (main_args->domain), main_args->file);
if (!assembly){
fprintf (stderr, "Can not open image %s\n", main_args->file);
exit (1);
}
/* View on GitHub (pinned to 0f53e9e151)
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.
Example fix
# before mono --aot MyApp.dll // mono_compile_assembly != 0 # after: read the error above, then disable LLVM for that image mono --aot=llvm=false MyApp.dll
Defensive patterns
Strategy: retry
Validate before calling
# Smoke-AOT a single image to surface the precise failure first
monodis --assembly "$IMG" >/dev/null 2>&1 || { echo "bad image: $IMG"; exit 1; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- AOT of mode-specific deferred assemblies failed.
- Can not open image %s
- Error: Loaded assembly '%s' doesn't match original file name
- max-heap-size must be at least %dMb.
- max-heap-size must be an integer.
AI-assisted analysis of mono/mono@0f53e9e151 (2026-08-13).
Data as JSON: /api/errors/36e6cc346cdc283d.
Report an issue: GitHub.