Guest User

Untitled

a guest
Oct 14th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.18 KB | None | 0 0
  1.     MonoDomain *domain;
  2.     MonoAssembly *assembly;
  3.     MonoImage *image;
  4.     mono_set_dirs("C:\\Program Files (x86)\\Mono-2.10.5\\lib","C:\\Program Files (x86)\\Mono-2.10.5\\etc");
  5.     mono_config_parse (NULL);
  6.     domain = mono_jit_init ("Q2");
  7.     assembly = mono_domain_assembly_open (domain, "Q2CIL.dll");
  8.     image = mono_assembly_get_image(assembly);
  9.  
  10.     mono_assemblies_init();
  11.  
  12.     if (assembly)
  13.     {
  14.         MonoObject *rv;
  15.         char *aaa[] =
  16.         {
  17.             { "./empty.exe " }
  18.         };
  19.         int ret = mono_jit_exec (domain, assembly, 1, aaa);
  20.  
  21.         /* we execute methods that take one argument */
  22.         void *args [1];
  23.         int val = 10;
  24.  
  25.         MonoMethodDesc *foo_method_desc = mono_method_desc_new("Q2CIL.Test:Foo(int)", FALSE);
  26.         MonoMethod *foo_method = mono_method_desc_search_in_image(foo_method_desc, image);
  27.         mono_method_desc_free(foo_method_desc);
  28.         /* Note we put the address of the value type in the args array */
  29.         args [0] = &val;
  30.  
  31.         /* execute Foo (10);
  32.         * it's a static method, so use NULL as the second argument.
  33.         */
  34.  
  35.         // exit(1)'s here with TypeLoadException:
  36.         rv = mono_runtime_invoke(foo_method, NULL, args, NULL);
  37.         ret = *(int*)mono_object_unbox (rv);
  38.  
  39.         printf("%i", ret);
  40.     }
  41.  
  42.     mono_jit_cleanup (domain);
  43.  
Advertisement
Add Comment
Please, Sign In to add comment