[runtime] Use IOAMP-aware method of looking for domain configuration file
[mono.git] / mono / metadata / icall.c
index 719e19ffbf3915122636657a8b141560bc7fa2d7..aed1b2cd274ba7b84943a998731ae9cc5aa5bf70 100644 (file)
@@ -77,6 +77,7 @@
 #include <mono/utils/mono-string.h>
 #include <mono/utils/mono-error-internals.h>
 #include <mono/utils/mono-mmap.h>
+#include <mono/utils/mono-io-portability.h>
 
 #if defined (HOST_WIN32)
 #include <windows.h>
@@ -6920,7 +6921,7 @@ get_bundled_app_config (void)
        const gchar *app_config;
        MonoDomain *domain;
        MonoString *file;
-       gchar *config_file;
+       gchar *config_file_name, *config_file_path;
        gsize len;
        gchar *module;
 
@@ -6932,15 +6933,20 @@ get_bundled_app_config (void)
                return NULL;
 
        // Retrieve config file and remove the extension
-       config_file = mono_string_to_utf8 (file);
-       len = strlen (config_file) - strlen (".config");
+       config_file_name = mono_string_to_utf8 (file);
+       config_file_path = mono_portability_find_file (config_file_name, TRUE);
+       if (!config_file_path)
+               config_file_path = config_file_name;
+       len = strlen (config_file_path) - strlen (".config");
        module = g_malloc0 (len + 1);
-       memcpy (module, config_file, len);
+       memcpy (module, config_file_path, len);
        // Get the config file from the module name
        app_config = mono_config_string_for_assembly_file (module);
        // Clean-up
        g_free (module);
-       g_free (config_file);
+       if (config_file_name != config_file_path)
+               g_free (config_file_name);
+       g_free (config_file_path);
 
        if (!app_config)
                return NULL;