[Mono-dev] Invoking .net interface method from c api

Robert Jordan robertj at gmx.net
Wed Aug 19 12:11:15 UTC 2015


On 19.08.2015 13:16, zebrajap wrote:
> Thanks for the help.
>
> I tried your suggestion but still it does not work.
>
> 92		MonoMethodDesc* pMethodDescCreateCompiler =
> mono_method_desc_new("System.CodeDom.Compiler.CodeDomProvider:CreateCompiler()",
> false);
> (gdb) n
> 93		MonoMethod* pMethodCreateCompiler = mono_method_desc_search_in_class
> (pMethodDescCreateCompiler, pCSharpCodeProviderClass);
> (gdb) n
> 94		pMethodCreateCompiler = mono_object_get_virtual_method(pCodeProvider,
> pMethodCreateCompiler);
> (gdb) n
> 95		MonoObject* pIcc = mono_runtime_invoke(pMethodCreateCompiler,
> pCodeProvider, NULL, NULL);
> (gdb) p pMethodCreateCompiler
> $1 = (MonoMethod *) 0x688810
> (gdb) p pCodeProvider
> $2 = (MonoObject *) 0x7ffff7f3ffc0
> (gdb) n
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff726bbc7 in ?? () from libmono.so.0

Try to invoke the method directly, i.e. w/out using an interface:

// Microsoft.CSharp.CSharpCodeProvider:CreateCompiler
MonoMethod *pMethodCreateCompiler =
   mono_class_get_method_from_name (pCSharpCodeProviderClass,
     "CreateCompiler", 0);

assert (pMethodCreateCompiler);

MonoObject *pIcc = mono_runtime_invoke (pMethodCreateCompiler,
   pCodeProvider, NULL, NULL);

Robert




More information about the Mono-devel-list mailing list