Sometimes we need to have decomposer tool or reflector tool for our applications to improve the performance or to know the internals of the assembly we have created. I was using Red Gate .NET Reflector earlier for same as it was free. Now Red Gate has made that tool paid version so I was finding some tools from that I can decompile the stuff. After digging some time on the internet I have found a great tool ILSpy which almost giving same functionalities like .NET Reflector. You can download that tool from following link.
http://wiki.sharpdevelop.net/ilspy.ashx
You will get following features in ILSpy. It is also listed on above page.
Now let’s see how we can use ILSpy for decompiling our application. I have created a very basic console application which will concat string and print name. Here I have intentionally used string concatenation instead of StringBuilder class to show what’s going internally with ILSpy. Following is code for that.
Once we are done with code let’s run that application and following will be a output.
Let’s check that console application with the ILSpy. Once you double click exe of ILSpy it will look like following.
Now let’s open our application via File->Open Menu. So it will load our application like following
As you can see in above screenshot It has loaded whole class hierarchy of console application we have just created as we can see Program and Test class directly and on right hand pane it has loaded whole assembly information for this application. You can see that in below image.
Now once you click on program it will load program information on right pane like following.
Event it’s provide IL mode also so you can see what’s going on internally on top its having button like this.
Once you select IL you right pane will load IL like following.In that you can see its using concat method
So you can see its almost providing functionalities which was provided by .NET Reflector. Hope you like it.. stay tuned for more..till then happy programming.
http://wiki.sharpdevelop.net/ilspy.ashx
You will get following features in ILSpy. It is also listed on above page.
- Assembly browsing
- IL Disassembly
- Decompilation to C#
- Supports lambdas and 'yield return'
- Shows XML documentation
- Saving of resources
- Search for types/methods/properties (substring)
- Hyperlink-based type/method/property navigation
- Base/Derived types navigation
- Navigation history
- BAML to XAML decompiler
- Save Assembly as C# Project
- Find usage of field/method
- Extensible via plugins (MEF)
using System; namespace ThisExample { class Program { static void Main(string[] args) { Test test = new Test(); test.PrintName(); } } public class Test { private string name = "Jalpesh Vadgama"; public void PrintName() { name += " vishal vadgama"; Console.WriteLine(name); } } }
Once we are done with code let’s run that application and following will be a output.
Let’s check that console application with the ILSpy. Once you double click exe of ILSpy it will look like following.
Now let’s open our application via File->Open Menu. So it will load our application like following
As you can see in above screenshot It has loaded whole class hierarchy of console application we have just created as we can see Program and Test class directly and on right hand pane it has loaded whole assembly information for this application. You can see that in below image.
Now once you click on program it will load program information on right pane like following.
Event it’s provide IL mode also so you can see what’s going on internally on top its having button like this.
Once you select IL you right pane will load IL like following.In that you can see its using concat method
So you can see its almost providing functionalities which was provided by .NET Reflector. Hope you like it.. stay tuned for more..till then happy programming.
0 comments:
Post a Comment
Your feedback is very important to me. Please provide your feedback via putting comments.