/** * Starts the mono runtime, and loads the encapsulated assembly, unless * it's already been loaded. */ void sp_ensure_runtime() { /* Check that the runtime hasn't already been started. */ if (runtime_started) { return; } /* Initialise the JIT. */ m_domain = mono_jit_init_version(__assembly_info.name, __assembly_info.version); if (!m_domain) { printf("error: unable to create mono domain\n"); _exit(0); } /* Open the assembly image, from the data inside the object * file. This data is accessed via the special symbols created * when the PE is linked in as a binary object. */ m_image = mono_image_open_from_data(&_binary_test_dll_start, &_binary_test_dll_end - &_binary_test_dll_start, 0, NULL); if (!m_image) { printf("error: unable to open assembly image\n"); _exit(0); } /* Now, load the assembly. */ m_assembly = mono_assembly_load_from_full(m_image, __assembly_info.name, NULL, 0); if (!m_assembly) { printf("error: unable to load assembly\n"); _exit(0); } /* Mark the runtime as started, just in case we neglected to * rewrite some function stubs. */ runtime_started = 1; }
static MonoReflectionAssembly * ves_icall_VInvoke_LoadAssemblyFromVirtuoso (MonoAppDomain *ad, MonoString *message) { char *asm_name; caddr_t name = NULL; caddr_t code = NULL; long len; MonoAssembly *ass; MonoDomain *domain = virtuoso_domain; MonoImage *image = NULL; #ifdef OLD_KIT_1_1_5 MonoImageOpenStatus *status; #else MonoImageOpenStatus status; #endif asm_name = mono_string_to_utf8 (message); name = box_copy (asm_name); code = mono_get_assembly_by_name (&name); if (!code) return NULL; len = box_length (code); image = mono_image_open_from_data (code, len, 0, NULL); if (!image) return NULL; #ifdef OLD_KIT_1_1_5 ass = mono_assembly_open ("", NULL, image); #else ass = mono_assembly_load_from (image, "", &status); #endif if (!ass && !status) return NULL; return mono_assembly_get_object (domain, ass); }