Hi All,

I'm using Mono.Cecil to dynamically generate an assembly. I'm encountering 
an error when attempting to verify the generated assembly using PEVerify:

An example for an error:

[IL]: Error: [D:\Output.dll : 
com.flurry.org.codehaus.jackson.map.util.Comparators::getArrayComparator][offset
 
0x0000000A] Unable to resolve token.

In this offset in IL i am calling a method that is referenced from another 
assembly. I am not sure whether i am using the API correctly.

Here's my code:

            var assemblyDefinition = new AssemblyNameDefinition("Output", 
new Version(1, 0, 0, 0));
            var asm = AssemblyDefinition.CreateAssembly(assemblyDefinition, 
"Output", ModuleKind.Dll);

            // The generated assembly imports a type from the current 
assembly to call its method.
            var proxy = asm.MainModule.Import(typeof(JavaProxy));
            var td = proxy.Resolve();

            var methodDefinition = td.Methods.First(md => md.Name == 
"Call");
            var methodReference = asm.MainModule.Import(methodDefinition);

Later on, adding a call to the methodReference:

          method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldstr, 
newType.FullName));
          method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldstr, 
method.Name));
          method.Body.Instructions.Add(Instruction.Create(OpCodes.Call, 
methodReference));
          method.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));


What am i doing wrong?

Any help would be appreciated.

Thanks,
Lior


-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to