0

I'm using the MS C# compiler to compile methods like this:

[Placeholder] public extern void Method();

The compiled method has RVA = 0 (Relative Virtual Address).

Then, with Mono.Cecil 0.9.3, I want to fill up a method body for it.

I do it like this:

methodDefinition.Body = new MethodBody(methodDefinition);
// emit code...

When trying to save the assembly, though, I get an error:

 System.NullReferenceException: Object reference not set to an instance of an object.
    at Mono.Cecil.Cil.CodeReader.IsInSection(Int32 rva)
    at Mono.Cecil.Cil.CodeReader.MoveTo(Int32 rva)
    at Mono.Cecil.Cil.CodeReader.PatchRawMethodBody(MethodDefinition method, CodeWriter writer, MethodSymbols& symbols)
    at Mono.Cecil.Cil.CodeWriter.WriteUnresolvedMethodBody(MethodDefinition method)
    at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method)

How can I make it work?

4

1 回答 1

1

I'm ashamed to say that the solution was to just upgrade Mono.Cecil to version 0.9.5.

于 2011-06-27T11:49:08.707 回答