如何引用另一个程序集文件并从中调用

How to reference another assembly file and call from it

大家好,根据我的经验,Mono.Cecil 的文档很少见,我似乎无法在任何地方找到答案。我正在尝试修改我的一个 Unity3D 游戏的 DLL 并添加一个新的 class,然后将一个名为 "Update" 的方法注入到那个 class 中。完成后,我想插入一条 IL 指令以从 unityEngine 调用 Input.GetKeyDown bool。但我似乎无法弄清楚如何实际引用它。当我尝试这样做时:

Instruction IL2 = method.Body.GetILProcessor().Create(OpCodes.Call,UnityEngine.Input.GetKeyDown);

我收到一个错误。任何帮助将不胜感激,因为我确定我不是唯一遇到此问题的人。

我的完整代码可以在 http://pastebin.com/1dug0LmA

查看

我找到了一种使用

来做到这一点的方法
asm.MainModule.Import((typeof(<type>).GetMethod("<Method Name>")));