Wednesday, June 23, 2010


                This is an Add-in to Visual Studio


                This helps us to view the MSIL (Microsoft Intermediate Language) generated for C# or VB.Net code we write.

Expected Users

                Those who are interested in studying -

                     How compiler is handling your code?

              How new language  features are implemented?


                What is the MSIL equivalent for ‘property’ in C# or VB.Net?

         When you write a property in C#, compiler is generating some methods corresponding to it. Eventhough .property is there, the get_property and set_property methods are the working methods


     public string Text { get; set; } is –

  1: .property instance string Text()
  2:  {
  3:    .get instance string Game.Classes.Dragger::get_Text()
  4:    .set instance void Game.Classes.Dragger::set_Text(string)
  5:  }
  7:  .method public hidebysig specialname instance string 
  8:          get_Text() cil managed
  9:  {
 10:    .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
 11:    // Code size       11 (0xb)
 12:    .maxstack  1
 13:    .locals init (string V_0)
 14:    IL_0000:  ldarg.0
 15:    IL_0001:  ldfld      string Game.Classes.Dragger::'<Text>k__BackingField'
 16:    IL_0006:  stloc.0
 17:    IL_0007:  br.s       IL_0009 
 19:    IL_0009:  ldloc.0
 20:    IL_000a:  ret
 21:  } // end of method Dragger::get_Text 
 23:  .method public hidebysig specialname instance void 
 24:          set_Text(string 'value') cil managed
 25:  {
 26:    .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
 27:    // Code size       8 (0x8)
 28:    .maxstack  8
 29:    IL_0000:  ldarg.0
 30:    IL_0001:  ldarg.1
 31:    IL_0002:  stfld      string Game.Classes.Dragger::'<Text>k__BackingField'
 32:    IL_0007:  ret
 33:  } // end of method Dragger::set_Text

Ie, for set and get methods with set_propertyName and get_propertyName are generated.

When you say – Text=”Hello”, compiler is doing – set_Text(“Hello”)


                 Download ILViewer from and install it.

Now you will  be able to see this plug in Visual Studio ‘Tools’ menu


Provide a shortcut key for ILViewer as –

                Go to: Tools => Environment => Keyboard

                Select ILViewer and provide shortcut key to be used. I am using ‘Ctrl+I’



Open a .cs or .vb file in Visual Studio and run the ILViewer (press your shortcut key for ILViewer).

Now you can see the IL generated for your code file as a new file opened in Visual Studio.



Now you can select ‘New Horizonrtal Tab Group’ option from Windows menu.


This will create two windows: one for C# or VB.Net code and the other for IL.


After making changes in C# code, click short key for ILViewer and see the MSIL getting changed in lower pane.


1.       Whenever ILViewer is running, the focus should be in .cs or .vb file. Else you will get an error message as follows –


2.         Make sure that your code file doesn’t have any partial class, whose partial definition is in some other file . This results in compilation error.

Happy Learning


  1. Good work dude :) Nice to see your posts coming out

  2. Kewl...Release the rest of your tools, you created so far, to the public. Could be beneficial to many of us :)

  3. Thank you Anoop and Hari.
    I will work on other tools and will publish to public.
    Thanks for your support