Wednesday, March 04, 2009

Exploring Assembly in .NET

The Intermediate Language Disassembler (ildasm.exe),which comes with the .NET SDK allows to view a dll contents,manifest CIL code and Metadata…

ildasm can be loaded from command prompt(start –> Programs –> Microsoft Visual Studio 2008 – > Visual Studio 2008 Command Prompt

for demonstration i have developed a class with contains a method for getting the TotalPrice

  





   1: using System;


   2: using System.Collections.Generic;


   3: using System.Linq;


   4: using System.Web;


   5:  


   6: namespace www.buddhasmiles.blogspot.com


   7: {


   8:     public class buddha_class


   9:     {


  10:         public decimal GetTotalPrice()


  11:         {


  12:             decimal grandTotalPrice = 0, itemTotalPrice = 0, itemDiscountedTotalPrice = 0, itemTotalPriceCommodtity = 0;


  13:  


  14:             itemDiscountedTotalPrice = Convert.ToDecimal("100");


  15:             grandTotalPrice += itemDiscountedTotalPrice;


  16:  


  17:             return grandTotalPrice;


  18:         }


  19:  


  20:     }


  21: }




i open the dll using the ildasm and here is the output



image



for viewing the CIL just double click each method



Lutz Roeder’s Reflector( http://www.aisto.com/roeder/dotnet.)



Another free tool similar like ildasm …a great s/w where we can see the code in multiple languages



image

No comments: