Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MonoDomain *domain;
- MonoAssembly *assembly;
- MonoImage *image;
- mono_set_dirs("C:\\Program Files (x86)\\Mono-2.10.5\\lib","C:\\Program Files (x86)\\Mono-2.10.5\\etc");
- mono_config_parse (NULL);
- domain = mono_jit_init ("Q2");
- assembly = mono_domain_assembly_open (domain, "Q2CIL.dll");
- image = mono_assembly_get_image(assembly);
- mono_assemblies_init();
- if (assembly)
- {
- MonoObject *rv;
- char *aaa[] =
- {
- { "./empty.exe " }
- };
- int ret = mono_jit_exec (domain, assembly, 1, aaa);
- /* we execute methods that take one argument */
- void *args [1];
- int val = 10;
- MonoMethodDesc *foo_method_desc = mono_method_desc_new("Q2CIL.Test:Foo(int)", FALSE);
- MonoMethod *foo_method = mono_method_desc_search_in_image(foo_method_desc, image);
- mono_method_desc_free(foo_method_desc);
- /* Note we put the address of the value type in the args array */
- args [0] = &val;
- /* execute Foo (10);
- * it's a static method, so use NULL as the second argument.
- */
- // exit(1)'s here with TypeLoadException:
- rv = mono_runtime_invoke(foo_method, NULL, args, NULL);
- ret = *(int*)mono_object_unbox (rv);
- printf("%i", ret);
- }
- mono_jit_cleanup (domain);
Advertisement
Add Comment
Please, Sign In to add comment