How to view Intermediate Language in C# using Ildasm.Exe

ILDASM (IL Disassembler) and ILASM (IL Assembler) – In this article, we will discuss What is Assembly and How to view Intermediate Language in C# using ildasm.exe.

ldasm.exe (IL Disassembler).NET Framework (current version) The IL Disassembler is a companion tool to the IL Assembler (Ilasm.exe).Ildasm.exe takes a portable executable (PE) file that contains intermediate language (IL) code and creates a text file suitable as input to Ilasm.exe.

what is intermediate language in .net framework

When we compile any .NET application the compiler will generate the assembly. Assembly generated will be in the format of .dll or .exe files based on the type of application we create.

  • Console Application and Windows Application will generate .exe file type assembly.
  • ASP.NET, MVC, Class Library etc will generate .dll file type assembly.

These assemblies files consists of Intermediate Language (IL) or Microsoft Intermediate Language (MSIL). The operating system will not understand the MSIL code as it can only understand the native code.

CLR called as Common Language Runtime is responsible for converting the MSIL code into Native Code which is understood  by the operating systems with the help of Just in Time (JIT) Compiler.

How to view Intermediate Language in C# using Ildasm.Exe

InOrder to view the assembly(.dll, .exe) Microsoft has built ILDASM(Intermediate Language DisAssembler) which will come when you install visual studio and .Net framework.

You could go to visual studio command prompt and type ildasm.exe command to open the IL DASM tool or locate the ildasm.exe using the path C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\ildasm.exe. Note the path might vary depending on the location of your windows and visual studio installation.

Hello, World Console Application Example to view intermediate code in C# using ildasm.exe

Well, this would be a simple program in C# which outputs the text Hello, World!!. Now let us open the assembly file using ILDASM and see how the code looks in below screenshot.

How to view Intermediate Language in C# using Ildasm.Exe

When you open the Assembly using ILDASM basically it is divided into 2 parts the first one is the MANIFEST and the second part is the actual code.

MANIFEST – Manifest contains the metadata information like (Public Token Key, Assembly Info, Assembly Version etc.)about the code which we have written.

Assembly – The other part is an assembly code itself which consists our application namespace, classes, constructors method names etc which we have coded in the application.

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *