mono/mono · error

This mono runtime is compiled for cross-compiling. Only the

Error message

This mono runtime is compiled for cross-compiling. Only the --aot option is supported.

What it means

Fatal error (exit 1) emitted only in MONO_CROSS_COMPILE builds when the user runs the cross-compiling runtime without requesting AOT compilation (mono_compile_aot is NULL/false). A cross-compiler runtime cannot execute assemblies; it can only produce AOT images, so any other action is rejected.

Source

Thrown at mono/mini/driver.c:2579

	 * If we are not embedded, use the mono runtime executable to run managed exe's.
	 */
	{
		char *runtime_path;

		runtime_path = mono_w32process_get_path (getpid ());
		if (runtime_path) {
			mono_w32process_set_cli_launcher (runtime_path);
			g_free (runtime_path);
		}
	}
#endif

	if (g_hasenv ("MONO_XDEBUG"))
		enable_debugging = TRUE;

#ifdef MONO_CROSS_COMPILE
       if (!mono_compile_aot) {
		   fprintf (stderr, "This mono runtime is compiled for cross-compiling. Only the --aot option is supported.\n");
		   exit (1);
       }
#if TARGET_SIZEOF_VOID_P == 4 && (defined(TARGET_ARM64) || defined(TARGET_AMD64)) && !defined(MONO_ARCH_ILP32)
       fprintf (stderr, "Can't cross-compile on 32-bit platforms to 64-bit architecture.\n");
       exit (1);
#endif
#endif

	if (mono_compile_aot || action == DO_EXEC || action == DO_DEBUGGER) {
		g_set_prgname (argv[i]);
	}

	mono_counters_init ();

#ifndef HOST_WIN32
	mono_w32handle_init ();
#endif

View on GitHub (pinned to 0f53e9e151)

Solutions

  1. Use the cross-compiling mono only with `--aot` to generate native images for the target.
  2. Install/select the host (non-cross) mono runtime on PATH if you intend to execute assemblies.
  3. If running a test, run it on the target device or under qemu with a proper runtime, not the cross-compiler.

Example fix

// before
mono-cross MyApp.exe   # tried to execute

// after
mono-cross --aot MyApp.exe   # generate AOT image
# or to execute: use the host mono runtime
Defensive patterns

Strategy: validation

Validate before calling

// Detect a cross-compile-only runtime and only allow --aot invocations.
const { execSync } = require('child_process');
function isCrossRuntime() {
  try {
    const out = execSync('mono --version 2>&1', { encoding: 'utf8' });
    return /cross|CROSS_COMPILE/i.test(out);
  } catch { return false; }
}
if (isCrossRuntime() && !args.includes('--aot')) {
  throw new Error('This mono is a cross-compiler; only --aot is supported.');
}

Prevention

When it happens

Trigger: Running a Mono binary built with MONO_CROSS_COMPILE defined, without an --aot request. The `if (!mono_compile_aot)` guard is true and exit(1) fires.

Common situations: Accidentally invoking the cross-compiler `mono` as if it were a normal runtime (e.g. to run a test). Confusing the cross-compile toolchain mono with the host runtime mono on the PATH.

Related errors


AI-assisted analysis of mono/mono@0f53e9e151 (2026-08-13). Data as JSON: /api/errors/1fe4699f18abb198. Report an issue: GitHub.