[netcore] Use the strict loader (mono/mono#15668)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Tue, 16 Jul 2019 18:30:16 +0000 (14:30 -0400)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Tue, 16 Jul 2019 18:30:16 +0000 (20:30 +0200)
Mono historically was quite lax in how it resolved assembly references - it
would pick the first assembly with a matching simple name.  The "strict"
mode (available in framework Mono with `--assembly-loader=strict`) follows the
spec behavior: the version and public key token of the candidate assembly must
match what is requested.

Commit migrated from https://github.com/mono/mono/commit/d8a679375d706e992d590c3eb90e1c57cb2864e7

src/mono/mono/mini/main-core.c

index e0f01d3..6ac0f1e 100644 (file)
@@ -227,6 +227,12 @@ int STDAPICALLTYPE coreclr_initialize (const char* exePath, const char* appDomai
        if (native_lib_paths != NULL)
                mono_set_pinvoke_search_directories (native_lib_paths->dir_count, native_lib_paths->dirs);
 
+       /*
+        * Don't use Mono's legacy assembly name matching behavior - respect
+        * the requested version and public key token.
+        */
+       mono_loader_set_strict_strong_names (TRUE);
+
        return 0;
 }