{"record":{"id":"ec36f123c4e5dd38","repo":"mono/mono","slug":"error-loaded-assembly-s-doesn-t-match-original","errorCode":null,"errorMessage":"Error: Loaded assembly '%s' doesn't match original file name '%s'. Set MONO_PATH to the assembly's location.\n","messagePattern":"Error: Loaded assembly '(.+?)' doesn't match original file name '(.+?)'\\. Set MONO_PATH to the assembly's location\\.\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"mono/mini/driver.c","lineNumber":1441,"sourceCode":"\t\tfor (i = 0; i < main_args->argc; ++i) {\n\t\t\tassembly = mono_domain_assembly_open_internal (main_args->domain, mono_domain_default_alc (main_args->domain), main_args->argv [i]);\n\t\t\tif (!assembly) {\n\t\t\t\tif (mono_is_problematic_file (main_args->argv [i])) {\n\t\t\t\t\tfprintf (stderr, \"Info: AOT of problematic assembly %s skipped. This is expected.\\n\", main_args->argv [i]);\n\t\t\t\t\tcontinue;\n\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);","sourceCodeStart":1423,"sourceCodeEnd":1459,"githubUrl":"https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/mini/driver.c#L1423-L1459","documentation":"In AOT mode, after loading an assembly Mono re-opens the same filename with mono_image_open and compares img->name against assembly->image->name. If they differ, the loader resolved the file to a different assembly than the one matched by name (an assembly-identity mismatch), and it exits(1). The message tells the user to set MONO_PATH to the assembly's real location.","triggerScenarios":"MONO_PATH or the default search path causes Mono to load an assembly whose AssemblyName does not match the file requested — typically because a different version or a same-named assembly in another directory was picked up. The strong/simple name comparison fails.","commonSituations":"Multiple assemblies with the same filename in different directories; MONO_PATH pointing at a shared GAC-like folder with a different version; shadow-copy or packaging putting the wrong file at the expected name; case-insensitive filesystem collisions.","solutions":["Set MONO_PATH to the exact directory containing the assembly you intend to AOT: export MONO_PATH=/abs/path/to/asm.","Remove or rename the conflicting same-named assembly elsewhere in the search path.","Pass the full absolute path to --aot instead of relying on search.","Verify the assembly's AssemblyName matches the file's expected identity (monodis --assembly)."],"exampleFix":"# before: MONO_PATH resolves a different Newtonsoft.Json\nmono --aot Newtonsoft.Json.dll\n# after\nMONO_PATH=/app/libs mono --aot /app/libs/Newtonsoft.Json.dll","handlingStrategy":"validation","validationCode":"# Ensure the requested file's AssemblyName matches what mono will resolve\nmonodis --assembly \"$ASM\" | grep -q \"Name: $EXPECTED\" || { echo \"identity mismatch\"; exit 1; }\nexport MONO_PATH=\"$(cd \"$(dirname \"$ASM\")\" && pwd)\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths and set MONO_PATH to the assembly's directory.","Avoid having same-named assemblies in multiple search-path folders.","Verify AssemblyName with monodis --assembly before AOT."],"tags":["mono","aot","assembly-loading","mono-path","startup"],"backgroundTag":null,"analyzedSha":"0f53e9e151d92944cacab3e24ac359410c606df6","analyzedAt":"2026-08-13T18:54:37.190Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}