How to insert CIL code to C#

前端 未结 5 2132
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 17:55

Is it possible to insert IL code to C# method?

5条回答
  •  情书的邮戳
    2021-02-01 18:15

    The tool you need is called Cecil and is a part of the Mono project.

    You can get more information about it here: http://www.mono-project.com/Cecil

    Quoted from the website above:

    Cecil is a library written by Jb Evain (http://evain.net/blog/) to generate and inspect programs and libraries in the ECMA CIL format. It has full support for generics, and support some debugging symbol format.

    In simple English, with Cecil, you can load existing managed assemblies, browse all the contained types, modify them on the fly and save back to the disk the modified assembly.

提交回复
热议问题