Hey Jan,

On Fri, Apr 30, 2010 at 9:19 AM, Jan <[email protected]> wrote:
> code is something like
> MethodReference mr = instruction.Operand
> TypeReference tr = mr.DeclaringType
> ParameterDefinition p = new ParameterDefinition(new
> ReferenceType(tr));
>
> I have tried .Resolve() and module.Import() at various places but
> without success. It seems that the tr is always refering to the wrong
> (my) assembly.

You don't need either of those :)

This code is just fine.

Resolve is the process of retrieving a Definition from a Reference. So
let say in module Foo you a reference to the type Bar.Bar in the
assembly Bar. Resolving this reference with open Bar.Bar.dll and get
you the Bar TypeDefinition. But you won't be able to use the
Definition in Foo, as they don't have the same module.

Import is the process of creating a reference in the module to
something defined in another module. So if you still have the
TypeDefinition of Bar in Bar.Bar.dll, you can Import it in Foo to be
able to use it.

The bug here is inside Cecil, it emits the full form of a reference to
System.Int32 in the signature of your new method instead of using the
native signature element for Int32.

-- 
Jb Evain  <[email protected]>

-- 
--
mono-cecil

Reply via email to