Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between IKVM.Reflection.Emit and Mono.Cecil

IKVM.Reflection.Emit has "the ability to read and emit .NET 1.1, .NET 2.0 and .NET 4.0 assemblies (while running on, for example, .NET 2.0).".

Does Mono.Cecil have the same? Are they interchangable for this use case? Are they both supported nowadays? What are key differences between them (in emitting IL)?

like image 203
Vlad Avatar asked Oct 21 '15 11:10

Vlad


1 Answers

I know this has been an old question, but I'd like to provide an answer. IKVM.Reflection.Emit API was invented when its author was tired of System.Reflection.Emit and Cecil.Reflection.Emit. In order to make IKVMC compiler faster, he worked from scratch to design this new API.

The history can be found from the following blog posts,

2008 Aug Switch from Microsoft .NET reflection to Cecil

2008 Nov Switch from Cecil to IKVM.Reflection.Emit

2010 Jan Announce IKVM.Reflection

So generally speaking IKVM.Reflection and Cecil have similar functionalities, and IKVM.Reflection API should be faster in many ways.

Up-to-now you can still see Cecil is widely used in many utilities (such as Obfuscar, an obfuscation tool I am maintaining). IKVM.Reflection is mainly used in Mono C# compiler and IKVM itself, and I am not sure whether there are other projects using it (but should be many).

like image 200
Lex Li Avatar answered Nov 07 '22 02:11

Lex Li