0

I'm trying to inject code into an assembly using Mono.Cecil. So far it's all been great but now I'm trying to implement this bit of IL:

call bool [mscorlib]System.String::op_Equality(string, string)

How do I do this in Cecil? I know it's something like

var il=mymethod.Body.GetIlProcessor();
...
il.Emit(Opcodes.Call, ????);

I don't know what kind of parameter to send in or how to get a reference to that static function.

How do I do this?

Earlz
  • 62,085
  • 98
  • 303
  • 499

1 Answers1

5

Something like this:

MethodReference ope = myMainModule.Import(typeof(string).GetMethod("op_Equality"));
il.Emit(Opcodes.Call, ope);
Simon Mourier
  • 132,049
  • 21
  • 248
  • 298