+ /* We need to check for ReferenceAssmeblyAttribute before we
+ * mark the assembly as loaded and before we fire the load
+ * hook. Otherwise mono_domain_fire_assembly_load () in
+ * appdomain.c will cache a mapping from the assembly name to
+ * this image and we won't be able to look for a different
+ * candidate. */
+
+ if (!refonly && strcmp (ass->aname.name, "mscorlib") != 0) {
+ /* Don't check for reference assmebly attribute for
+ * corlib here because if corlib isn't loaded yet,
+ * it's too early to set up the
+ * ReferenceAssemblyAttribute class. We check that
+ * we're not running with a reference corlib in
+ * mono_init_internal().
+ */
+ MonoError refasm_error;
+ if (mono_assembly_has_reference_assembly_attribute (ass, &refasm_error)) {
+ mono_assemblies_unlock ();
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Image for assembly '%s' (%s) has ReferenceAssemblyAttribute, skipping", ass->aname.name, image->name);
+ g_free (ass);
+ g_free (base_dir);
+ mono_image_close (image);
+ *status = MONO_IMAGE_IMAGE_INVALID;
+ return NULL;
+ }
+ mono_error_cleanup (&refasm_error);
+ }
+