How to view msil code using Visual studio

Lionsure 2020-09-19 Original by the website

The msil code is the intermediate code that us compiled into the target program in .net. Knowing how to view and analyze it will help you better understand .net and improve programming efficiency. As a programmer, it is necessary to understand this. What are the ways to check it?

 

How to view msil code in C#?

I. View msil code in C# using ildasm.exe provided by Visual studio 2005(2008, 2010, 2012, 2015, 2017, 2019, etc.)

We take the ildasm.exe provided by Visual studio 2005 and 2019 as examples to illustrate the specific viewing steps, and the operation steps for other versions are the same.

1. Select "Start" -> Visual studio 2019 (folder) -> Developer Command Prompt for VS 2019, and open the "Developer Command Prompt for VS 2019" window.

Visual studio 2005: select "Start" -> "All Programs" -> "Visual studio 2005" -> "Visual studio 2005 Tools" -> "Visual studio 2005 Command Prompt", open "Visual studio 2005 Command Prompt" window.

 

2. Type ildasm, and press Enter to open the "IL DASM" window.

3. Select "File" -> "Open" in the menu bar in turn, and then select a dll file, and you may see the msil code.

 

II. View msil code in C# using other free tools

 In addition to Visual Studio, which can view msil code, there are also some free viewing tools on the Internet. For example, JustCompiler is a free viewing tool. The capacity of the tool itself is very small, and it can be used after downloading quickly. If Visual Studio is not installed, it is a good choice.