#include <mono/metadata/mono-config.h>
#include <mono/utils/mono-digest.h>
#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-path.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/coree.h>
/* Contains the list of directories that point to auxiliary GACs */
static char **extra_gac_paths = NULL;
+#ifndef DISABLE_ASSEMBLY_REMAPPING
/* The list of system assemblies what will be remapped to the running
* runtime version. WARNING: this list must be sorted.
*/
{"System.Xml", 0},
{"mscorlib", 0}
};
+#endif
/*
* keeps track of loaded assemblies
mono_set_rootdir (void)
{
#if defined(HOST_WIN32) || (defined(PLATFORM_MACOSX) && !defined(TARGET_ARM))
- gchar *bindir, *installdir, *root, *name, *config;
+ gchar *bindir, *installdir, *root, *name, *resolvedname, *config;
#ifdef HOST_WIN32
name = mono_get_module_file_name ((HMODULE) &__ImageBase);
fallback ();
return;
}
+
+ name = mono_path_resolve_symlinks (name);
}
#endif
- bindir = g_path_get_dirname (name);
+ resolvedname = mono_path_resolve_symlinks (name);
+
+ bindir = g_path_get_dirname (resolvedname);
installdir = g_path_get_dirname (bindir);
root = g_build_path (G_DIR_SEPARATOR_S, installdir, "lib", NULL);
g_free (installdir);
g_free (bindir);
g_free (name);
+ g_free (resolvedname);
#elif defined(DISABLE_MONO_AUTODETECTION)
fallback ();
#else
char*
mono_stringify_assembly_name (MonoAssemblyName *aname)
{
+ const char *quote = g_ascii_isspace (aname->name [0]) ? "\"" : "";
+
return g_strdup_printf (
- "%s, Version=%d.%d.%d.%d, Culture=%s, PublicKeyToken=%s%s",
- aname->name,
+ "%s%s%s, Version=%d.%d.%d.%d, Culture=%s, PublicKeyToken=%s%s",
+ quote, aname->name, quote,
aname->major, aname->minor, aname->build, aname->revision,
aname->culture && *aname->culture? aname->culture: "neutral",
aname->public_key_token [0] ? (char *)aname->public_key_token : "null",
InterlockedIncrement (&assembly->ref_count);
}
+#ifndef DISABLE_ASSEMBLY_REMAPPING
static MonoAssemblyName *
mono_assembly_remap_version (MonoAssemblyName *aname, MonoAssemblyName *dest_aname)
{
}
return aname;
}
+#endif
/*
* mono_assembly_get_assemblyref:
if (reference != REFERENCE_MISSING){
mono_assembly_addref (reference);
if (image->assembly)
- mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Assembly Ref addref %s %p -> %s %p: %d\n",
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Assembly Ref addref %s %p -> %s %p: %d",
image->assembly->aname.name, image->assembly, reference->aname.name, reference, reference->ref_count);
} else {
if (image->assembly)
/* Add a non-temporary reference because of ass->image */
mono_image_addref (image);
- mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Image addref %s %p -> %s %p: %d\n", ass->aname.name, ass, image->name, image, image->ref_count);
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Image addref %s %p -> %s %p: %d", ass->aname.name, ass, image->name, image, image->ref_count);
/*
* The load hooks might take locks so we can't call them while holding the
mono_assembly_load_with_partial_name (const char *name, MonoImageOpenStatus *status)
{
MonoAssembly *res;
- MonoAssemblyName *aname, base_name, maped_aname;
+ MonoAssemblyName *aname, base_name;
+#ifndef DISABLE_ASSEMBLY_REMAPPING
+ MonoAssemblyName maped_aname;
+#endif
gchar *fullname, *gacpath;
gchar **paths;
if (!mono_assembly_name_parse (name, aname))
return NULL;
+#ifndef DISABLE_ASSEMBLY_REMAPPING
/*
* If no specific version has been requested, make sure we load the
* correct version for system assemblies.
*/
if ((aname->major | aname->minor | aname->build | aname->revision) == 0)
aname = mono_assembly_remap_version (aname, &maped_aname);
+#endif
res = mono_assembly_loaded (aname);
if (res) {
mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *status)
{
char *corlib_file;
+ MonoAssemblyName *aname;
if (corlib) {
/* g_print ("corlib already loaded\n"); */
return corlib;
}
#endif
-
+
+ aname = mono_assembly_name_new ("mscorlib.dll");
+ corlib = invoke_assembly_preload_hook (aname, assemblies_path);
+ mono_assembly_name_free (aname);
+ if (corlib != NULL)
+ return corlib;
+
if (assemblies_path) {
corlib = load_in_path ("mscorlib.dll", (const char**)assemblies_path, status, FALSE);
if (corlib)
{
MonoAssembly *result;
char *fullpath, *filename;
- MonoAssemblyName maped_aname, maped_name_pp;
+#ifndef DISABLE_ASSEMBLY_REMAPPING
+ MonoAssemblyName maped_aname;
+#endif
+ MonoAssemblyName maped_name_pp;
int ext_index;
const char *ext;
int len;
+#ifndef DISABLE_ASSEMBLY_REMAPPING
aname = mono_assembly_remap_version (aname, &maped_aname);
+#endif
/* Reflection only assemblies don't get assembly binding */
if (!refonly)
mono_assembly_loaded_full (MonoAssemblyName *aname, gboolean refonly)
{
MonoAssembly *res;
+#ifndef DISABLE_ASSEMBLY_REMAPPING
MonoAssemblyName maped_aname;
aname = mono_assembly_remap_version (aname, &maped_aname);
+#endif
res = mono_assembly_invoke_search_hook_internal (aname, refonly, FALSE);