+MonoAssembly*
+mono_assembly_load (MonoAssemblyName *aname, const char *basedir, MonoImageOpenStatus *status)
+{
+ MonoAssembly *result;
+ char *fullpath, *filename;
+
+ check_env ();
+
+ /* g_print ("loading %s\n", aname->name); */
+ /* special case corlib */
+ if ((strcmp (aname->name, "mscorlib") == 0) || (strcmp (aname->name, "corlib") == 0)) {
+ if (corlib) {
+ /* g_print ("corlib already loaded\n"); */
+ return corlib;
+ }
+ /* g_print ("corlib load\n"); */
+ if (assemblies_path) {
+ corlib = load_in_path (CORLIB_NAME, assemblies_path, status);
+ if (corlib)
+ return corlib;
+ }
+ fullpath = g_concat_dir_and_file (MONO_ASSEMBLIES, CORLIB_NAME);
+ corlib = mono_assembly_open (fullpath, status);
+ g_free (fullpath);
+ return corlib;
+ }
+ result = search_loaded (aname);
+ if (result)
+ return result;
+ /* g_print ("%s not found in cache\n", aname->name); */
+ if (strstr (aname->name, ".dll"))
+ filename = g_strdup (aname->name);
+ else
+ filename = g_strconcat (aname->name, ".dll", NULL);
+ if (basedir) {
+ fullpath = g_concat_dir_and_file (basedir, filename);
+ result = mono_assembly_open (fullpath, status);
+ g_free (fullpath);
+ if (result) {
+ g_free (filename);
+ return result;
+ }
+ }
+ if (assemblies_path) {
+ result = load_in_path (filename, assemblies_path, status);
+ if (result) {
+ g_free (filename);
+ return result;
+ }
+ }
+ result = load_in_path (filename, default_path, status);
+ g_free (filename);
+ return result;
+}
+