[Mono-dev] Registering internal calls at runtime

Michel Boissé mboisse at noesisinnovation.net
Tue Jul 13 18:37:19 EDT 2010


>> You cannot register the icall from within a method that eventually
>> calls the icall because the JIT does not know about the icall
>> at the time it compiles the method.
>>
>> Something like that should work:
>>
>> static void Main(string[] args)
>> {
>>       Registrar.RegisterMethods();
>>       DoWork();
>> }
>
> Just in case, inlining should be disabled for this method:
>
> [MethodImplAttribute(MethodImplOptions.NoInlining)]
> static void DoWork()
> {
>       Console.Write(InternallyImplementedClass.InternalMethod());
> }

Moving the call to a different function with the NoInlining option isn't 
working either.

We are digging deeper. We moved InternallyImplementedClass to a separate 
assembly. It still doesn't work. Here's how it looks now:

    1) DLL is loaded and registration is called from a static constructor 
before Main( ) starts executing
    2) Main( ) starts and InternallyImplementedClass' assembly is loaded 
through reflection
    4) InternalMethod is fetched and invoked through reflection
    5) Exception thrown: "System.MissingMethodException: Cannot find the 
requested method."

We'll have to hack in and see what's going on.
 



More information about the Mono-devel-list mailing list