Explore C# Assembly by using ildasm.exe

 

As we know any C# application converts into MSIL( Microsoft Intermediate Language) which is stored as assembly. Sometimes we might require to analyses this MSIL code that means we have to read the Assembly content. By using ildasm.exe tool which is part of Visual Studio framework helps you to explore the assembly code.


Write simple C# console application as shown below.

 

using System;

 

namespace CsharpApplication

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("This is the example to explore ildasm.exe");

            Console.ReadLine();

        }

    }

}

 

Build the application to generate the assembly. After build go to bin folder of Debug or Release folders, you can find CsharpApplication.vshost.exe file.


Now execute ildasm.exe in Microsoft Visual Studio Command Prompt as shown below.



It opens ildasm window as shown below.



From IL DASM window, select File => Open => open CsharpApplication.vshost.exe file, it opens the CsharpApplication assembly info as shown below.



If you want to see IL code double click on Main in the above window, it opens IL code as shown below.



If you want to see metadata double click on Mainfest, it opens below window.