Click here to Skip to main content
15,895,815 members
Articles / All Topics

ILSpy – Debugging 3rd Party .NET Libraries

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
15 Jul 2015CPOL2 min read 6.3K  
How to debug 3rd party .NET libraries

If you work with 3rd party .NET libraries, you may find yourself in a situation where you would really, really like to see what is going on “beneath the hood” of that black box, 3rd party assembly you are using. I have encountered cases where the API documentation wasn’t really clear as to what a method would do with a particular parameter. I have also had cases where the 3rd party library failed on a call and the cause wasn’t readily discoverable. For these cases, I have called on a very cool tool, Lutz Roeder’s .NET Reflector. Unfortunately, that tool has now become a commercial, pay-to-use product of Red Gate Software. There are several nice additions Red Gate has made to the tool, but for simple decompilation, I recommend the use of the open source, ILSpy tool.

ILSpy is a free, no-frills, .NET decompiler that uses reflection to IL to rebuild code back into C# syntax. It is a very useful tool and can help with the problems I mentioned before where you really need to see inside assemblies where you don’t have access to the source code. You can see from this example that I used ILSpy to look into the TryOpen method of the vdDocument class from VectorDraw, a 3rd party control for CAD rendering. I wondered what was going on with file formats that are not native to VectorDraw (i.e., *.vdml and *.vdcl).

ILSpy Showing the vdDocument.TryOpen Method

ILSpy showing the vdDocument.Open method

I drilled into the vdDocument.Open method simply by clicking on the method in the deconstructed code. That led me to the vdDocument.Open method and the ILSpy seamlessly displayed the code for the method:

ILSpy Showing the vdDocument.TryOpen Method

ILSpy showing the vdDocument.TryOpen method

From here, ILSpy shows me the code that it has reconstructed. I can clearly see the branching around the file types and I can continue to drill down through this code. I can use this to determine intent for the method or I can use this to see how parameters are used in their code. This definitely comes in handy when there is some confusion around the use of a particular method.

I highly recommend ILSpy for all your .NET decompilation needs. It is fast, detailed, and best of all, it is free!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
United States United States
I'm a learner/coder/leader who is curious about how technologies and people work together to solve interesting problems. I have a passion for software and doing what I can to improve the lives of the people who create and use it.

Comments and Discussions

 
-- There are no messages in this forum --