Hey,

I added some comments inline:

On Tue, Sep 7, 2010 at 3:41 PM, Vijay <[email protected]> wrote:
>            foreach (var mi in typeof(string).GetMethods())
>            {
>                var mr =
> body.Method.Module.Assembly.MainModule.Import(mi);
>                body.Method.Module.Assembly.MainModule.Import(mr);
>            }

What are you trying to do here? That's just a giant useless no-op.

>            foreach (var local in methodBody .Body.Variables)
>            {
>                body.Variables.Add(local);
>            }

You can't reuse a variable from another method. You have to create
another one with the proper type.

>            foreach (var instruction in methodBody.Body.Instructions)
>            {
>                worker.Append(instruction);
>            }

And you certainly can't add an instruction from one body to another.
You have to create a new body with the proper operands.

Basically you're trying to re-create a method from one assembly into
another. It's no easy nor small task, you have to properly re-create
everything and properly import what's needed.

-- 
Jb Evain  <[email protected]>

-- 
--
mono-cecil

Reply via email to