IL code versus IL assembly: is there a difference?

If I run the .NET compiler, it creates a file containing intermediate language (IL) code and places it in a .exe file (for example).

After I use a tool like ildasm, it will show me the IL code again.

However, if I write directly to the IL code file, then I can use ilasm to create the .exe file.

What does it contain? IL code again? Is IL code different from IL build code?

Is there any difference between IL code and IL assembly?

+8
c #
source share
2 answers

The .NET node does not contain MSIL; it contains metadata and bytes that represent IL IL codes. Pure binary data, not text. Any .NET decompiler, such as ildasm.exe, knows how to convert bytes to text. This is pretty straight forward.

The C # compiler directly generates binary data, there is no intermediate text format. When you write your own IL code using a text editor, you need ilasm.exe to convert it to binary. This is pretty straight forward.

The most difficult task of generating binary data is btw metadata. It is overly micro-optimized to make it as small as possible, its structure is quite curved. No compiler generates bytes directly; they will use a pre-built component to do this work. It is noteworthy that Roslin had to rewrite this from scratch, a lot of work.

+3
source share

Yes, there is a big difference between them, because:

  • (IL), which is also known as Microsoft Intermediate Language or Common Intermediate Language, can be considered very similar to the bytecode generated by the Java language, and I think you are referring to the IL code in your question.

  • (ILAsm) has a set of instructions, the same as the native assembly language. You can write code for ILAsm in any text editor such as Notepad, and then use the command line compiler (ILAsm.exe) provided by the .NET platform to compile this.

I think that the IL assembly can be considered as a full-fledged .NET language (possibly an intermediate language), so when you compile ILAsm using ILAsm.exe, you arbitrarily create IL in almost the same way (with smaller steps) so that your C # the compiler does with c # code ...

As someone said in a comment, IL Assembly is basically a user-readable version of .NET byte code.

+7
source share

All Articles