[Mono-dev] Re: emitting a MethodInfo instance

Jb Evain mono at evain.net
Sat Aug 13 15:21:53 EDT 2005


Hello,

I've added a patch in bugzilla to fix this.
However, your test case unveils another bug: ildasm fails to load  
assemblies references if they are .exe instead of .dll.

Jb

On Aug 12, 2005, at 5:37 PM, Valient Gough wrote:

> Adding a followup for list-archive completeness.
>
> On 5/31/05, Valient Gough <valient at gmail.com> wrote:
>
>
>> Forgot to add, my first guess was actually to use OpCode.Ldtoken to
>> directly load MethodInfo
>>
>
>
>> However, when I try and emit (OpCode.Ldtoken, MethodInfo), that  
>> causes
>> the ILGenerator to halt in mid-opcode, and monodis shows that last
>> opcode as "ldtoken" with no args..  Perhaps ILGenerator.Emit(OpCode,
>> MethodInfo) only works in mono 1.1.7 where OpCode == OpCode.Call* ?
>>
>
> Mono is able to emit the code, but monodis can't seem to decompile it.
> Ref bug #75544: http://bugzilla.ximian.com/show_bug.cgi?id=75544
>
> The following code will emit a MethodInfo reference into IL code, and
> the code will work fine, but it will render the resulting .dll
> undecodable by monodis:
>
> void Emit_MethodInfo(ILGenerator ig, MethodInfo method)
> {
>     ig.Emit( OpCodes.Ldtoken, method ); // this crashes monodis
>     ig.Emit( OpCodes.Call,
>              typeof(MethodBase).GetMethod("GetMethodFromHandle");
>     ig.Emit( OpCodes.Castclass, typeof(MethodInfo) );
> }
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>




More information about the Mono-devel-list mailing list