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

Csharp
Csharp

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

Welcome to CodeSpread!

Hi guys, this is Sathish again, today let’s discuss how to view the intermediate code in c#.
We know that CLR (Common Language Runtime) is used to convert the MSIL (Microsoft Intermediate Language) which is a pseudo code, into an executable program when a program runs.
Knowing this, let’s discuss how to view MSIL using ILDASM.exe.

MSIL Disassembler

MSIL Disassembler is a companion tool to the MSIL Assembler (Ilasm.exe). Ildasm.exe takes a portable executable (PE) file that contains Microsoft intermediate language (MSIL) code and creates a text file suitable as input to Ilasm.exe.

This tool is automatically installed with Visual Studio and with the Windows SDK.

To run the tool, we recommend that you use the Visual Studio Command Prompt or the Windows SDK Command Prompt (CMD Shell).

This is the Program where it returns the no of objects created for a class


using System; 
using System.Collections.Generic;
using System.Linq; 
using System.Text;

namespace Chap1_3 
{ 
class Program 
{ 
static int count; public Program() 
{
 ++count; 
} 
static void Main(string[] args) 
{ 
Program p1 = new Program(); 
Program p2 = new Program(); 
Console.WriteLine("The No of Objects created for the class is : {0} ", count); 
Console.ReadKey(true);
} 
} 
}

// Output

objectsildasm

objects-ildasm

Now let’s see what will be the Intermediate code for this program using ildasm.exe, and then go to following path
C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\ildasm.exe

If u open ildasm.exe It will pop up with a new Window, Then in a File menu choose open File, Then go to the debug folder and choose the .exe file of the project,the screen would look like below.

ildasm

ildasm

The Submenus defines the method, variables that are used within the program, to view the intermediate code of the function, just double click on it. This is the intermediate code for main function

mainFunc

mainFunc

Hope it helps you in checking the intermediate code of the program, Post your valuable comments to admin@codespread.com or at my personal id sathishkum1991@gmail.com

Author: Sathish

I just loved to express myself...

Share This Post On

0 Comments

  1. nice superb explaination

    Post a Reply
  2. thanks for the tutorial
    I am having a problem.
    The feature “Create SQL server database” isn’t available , I can’t select it.
    Can you help, please ?

    Post a Reply

Submit a Comment

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

More from CodeSpread:

  • Few lines about Static code analysisFew lines about Static code analysisStatic code analysis We divide the term into two parts: Static+code analysis. Static in programming can be referred to as non-running/non-dynamic and code analysis is a process where the code is...
  • Consider Structs Consider Structs While taking birth in programming world, we all had our own experiences of learning; begin working on a new language or OOPS concepts or experimenting with a new tool or compilers. One of such expe...
  • Get Educated: C# language 5.0 SpecificationsGet Educated: C# language 5.0 SpecificationsVery often,Developers ask me to write something about C# Language Specifications and I always ask them to refer Microsoft Download center. I think this is a pretty easy act as C# Language Specifica...
  • Why Multiple Inheritance is discouraged?Why Multiple Inheritance is discouraged?Hi Guys, This is Sathish Again,Today we will discuss why most of the higher languages eliminates Multiple Inheritance? Most of you guys already know that multiple inheritance is not available for...
  • How to make a Connection between c# and mysql?How to make a Connection between c# and mysql?This is my first article on codespread.com, titled ‘Connection between c# and mysql’.Before going into details, we should know that mysql is a open source software for data base management system. ...
  • Tip : Code Structure C#Tip : Code Structure C#As a developer, I always stress on developing a habit of following the best practices to structure the code. It helps me to easily navigate through the code and also saves a lot of effort in search...
  • My first experience with LISTS in C#My first experience with LISTS in C#Hi guys, this is Sathish, Lets discuss the concepts of lists. These are the concepts which I have planned to discuss with you guys today. What is a List and how it is advantageous than array...
  • Styles of Source Code Comments in C#, SQL, XML, HTML, CSS, JavaScriptStyles of Source Code Comments in C#, SQL, XML, HTML, CSS, JavaScriptDevelopers take months to write beautiful pieces of code and reviewer gets only few hours or I say, minutes to provide suggestions and improvisations. Then it becomes a hard deal for a developer to...