1 #include <mono/interpreter/embed.h>
2 #include <mono/metadata/environment.h>
5 * Very simple mint embedding example.
7 * gcc -o testi testi.c `pkg-config --cflags --libs mint` -lm
15 return mono_string_new (mono_domain_get (), "All your monos are belong to us!");
26 static void main_thread_handler (gpointer user_data
)
28 MainThreadArgs
*main_args
=(MainThreadArgs
*)user_data
;
29 MonoAssembly
*assembly
;
31 assembly
= mono_domain_assembly_open (main_args
->domain
,
36 * mono_jit_exec() will run the Main() method in the assembly.
37 * The return value needs to be looked up from
38 * System.Environment.ExitCode.
40 mono_interp_exec (main_args
->domain
, assembly
, main_args
->argc
,
46 main(int argc
, char* argv
[]) {
50 MainThreadArgs main_args
;
53 fprintf (stderr
, "Please provide an assembly to load\n");
58 * mono_jit_init() creates a domain: each assembly is
59 * loaded and run in a MonoDomain.
61 domain
= mono_interp_init (file
);
63 * We add our special internal call, so that C# code
66 mono_add_internal_call ("MonoEmbed::gimme", gimme
);
68 main_args
.domain
=domain
;
70 main_args
.argc
=argc
-1;
71 main_args
.argv
=argv
+1;
73 mono_runtime_exec_managed_code (domain
, main_thread_handler
,
76 retval
=mono_environment_exitcode_get ();
78 mono_interp_cleanup (domain
);