void Application::InitializeMono() { //this will override the internal assembly search logic. //do it in case you package mono in a different structure //mono_set_assemblies_path(dllDir.c_str()); mono_config_parse(NULL); // initialize the root domain which will hold corlib and will always be alive domain = mono_jit_init_version("CCubed Root Domain", "v4.0.30319"); // soft debugger needs this mono_thread_set_main(mono_thread_current()); // add icalls mono_add_internal_call("EmbedThings.EntryPoint::reload", reload); // run the c# bits Run(); // we're exiting the whole thing, cleanup mono_jit_cleanup(mono_domain_get()); }
void set_main_thread(MonoThread *p_thread) { mono_thread_set_main(p_thread); }
void mono_init_virt () { const char *error; #ifndef MONO_AGENT char * cfg_mono_root_path; char * cfg_mono_cfg_dir; char * cfg_mono_path; char * cfg_mono_trace; /*g_log_set_always_fatal (G_LOG_LEVEL_ERROR); g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR);*/ #ifndef VIRT_MINT if (virtuoso_cfg_getstring ("Mono", "MONO_TRACE", &cfg_mono_trace) != -1) mono_jit_trace_calls = strcmp (cfg_mono_trace, "On") ? FALSE : TRUE; #endif if (virtuoso_cfg_getstring ("Mono", "MONO_PATH", &cfg_mono_path) != -1) setenv ("MONO_PATH", cfg_mono_path, 1); if (virtuoso_cfg_getstring ("Mono", "MONO_ROOT", &cfg_mono_root_path) != -1) setenv ("MONO_ROOT", cfg_mono_root_path, 1); if (virtuoso_cfg_getstring ("Mono", "MONO_CFG_DIR", &cfg_mono_cfg_dir) != -1) setenv ("MONO_CFG_DIR", cfg_mono_cfg_dir, 1); if (virtuoso_cfg_getstring ("Mono", "virtclr.dll", &VIRTCLR_NAME) == -1) VIRTCLR_NAME = "virtclr.dll"; #endif #ifdef WIN32 /* mono initialization on win32 has to be done sooner than later */ #ifdef VIRT_MINT virtuoso_domain = mono_interp_init ("virtuoso"); #else virtuoso_domain = mono_jit_init ("virtuoso"); #endif if (cfg_mono_root_path) mono_assembly_setrootdir (cfg_mono_root_path); #endif #ifndef VIRT_MINT mono_jit_trace_calls = FALSE; #endif { char *path = getenv ("MONO_ROOT"); if (path) mono_assembly_setrootdir (path); } /* mono_debug_init (1); */ #ifndef WIN32 setlocale(LC_ALL, ""); #endif g_log_set_always_fatal (G_LOG_LEVEL_ERROR); g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR); g_set_printerr_handler (dummy_print); #ifndef WIN32 #ifdef VIRT_MINT virtuoso_domain = mono_interp_init ("virtuoso"); #else virtuoso_domain = mono_jit_init ("virtuoso"); #endif mono_config_parse (NULL); #ifdef OLD_KIT if (NULL != (error = mono_verify_corlib ())) #elif !defined (OLD_KIT_1_1_5) if (NULL != (error = mono_check_corlib_version ())) #endif { log_error ("Mono Corlib not in sync with this runtime: %s", error); exit (-1); } #ifndef VIRT_MINT #ifdef OLD_KIT_1_1_5 mono_thread_attach_aborted_cb = virt_mono_throw_unhandled_exception; #else mono_thread_set_attach_aborted_cb (virt_mono_throw_unhandled_exception); #endif #endif #endif mono_add_internal_call ("VInvoke::LoadAssemblyFromVirtuoso(string)", ves_icall_VInvoke_LoadAssemblyFromVirtuoso); #ifndef MONO_AGENT mono_set_port (); #endif #ifndef MONO_AGENT #ifdef OLD_KIT_1_1_4 log_debug ("Mono config path [%s]", mono_cfg_dir); #else log_debug ("Mono config path [%s]", mono_get_config_dir ()); #endif #endif #ifndef WIN32 setlocale (LC_ALL, "C"); #endif #ifndef OLD_KIT_1_1_5 mono_thread_manage (); mono_thread_set_main (mono_thread_current()); #endif }