25

Would you recommend a free tool for exploring compiled .NET assemblies. I need to be able to:

  • Explore the assemblies' source code and visualize the IL to a CLR language of choice (C#, VB.NET, managed C++ and etc.)
  • Support navigation between the classes (via Ctrl + click on the class name for example, or other convenient way).
  • Allow examining the embedded resources in the assembly, if any (text, images etc.)
  • Capable of handling assemblies since .NET version 2.0.

Optionally, I will be glad if it supports:

  • Exporting classes to source files.
  • Integration with Visual Studio 2010 (this one need not be free) that allows for debugging the source code.
  • Integration with the Xamarin Studio IDE (former MonoDevelop) would be a plus, although I am getting too optimistic here.

I used to work with .NET Reflector a few years ago and it supported most of the above features (actually all except the Xamarin integration). I tried to use it again a few weeks ago but now it has become a commercial product and my old free version does not work anymore.

4 Answers 4

18

ILSpy is one of the more popular FOSS .NET decompilers. It's pretty intuitive to use, though I have not yet tried Reflector so I can't compare them.

In its current version (8.2), it only supports decompilation to C# or IL. Previous support for decompilation to VB.NET was removed, and C++/CLI was never supported.

You can click on class and method names to navigate to their definitions, or analyse them through the context menu for where they are accessed. It can render both images and text from embedded resources, and allows you to save them - I have not tried other filetypes, but they should work in the same way.

You can export classes to source files, and you can even export entire assemblies into .csproj (MS build) files. For simpler projects these can be compiled directly. Many more complex projects tend to fail to compile without modification - notably, their site mentions it can't decompile and then recompile itself. If you need to decompile an entire assembly, you would likely have a lot of work left to get it to a compilable state.

Unfortunately, decompilation is not perfect. Some more complex language constructs, are not yet supported and can result in somewhat garbled output. You can still get the general algorithm through the clutter, but it certainly wouldn't work if you just wanted to copy some code. Language feature support status can be found here.

ILSpy is the implementation behind the built-in decompilation support in VS 2022, 2019 16.5+, and VSCode.


If you want other options, there's also dotPeek.

1
  • Great explanation, thanks! The C++/CLI is an option I can live without, and exporting to entire project seems a cool feature. The Xamarin Studio is somewhat of a recent player, as MonoDevelop (its former self) was of unclear fate a few years back. The SharpDevelop IDE support can drag me into getting to know that IDE too. I think the garbled output is always an issue with decompiling, and I doubt someone would use one-to-one decompiled code in an actual project. The ILSpy then seems a sufficient tool for my needs. Commented Feb 7, 2014 at 22:59
12

There is another tool developed by telerik - JustDecompile. It works really well, and has all the features of .NET Reflector and then some. (Including a visual studio extension). It's also free, which is nice. I've used it every since it came out and its quite nice.

One of my favorite features, is located under the tools menu "Create Project", it takes the assembly and build a csproj file out of it.

Just Decompile With Mysql data provider

1
  • Unfortunately JustDecompile appears to be discontinued with no downloads available as of 2024.
    – Bob
    Commented Sep 8 at 18:21
8

I personally am a big fan of dotPeek from Jetbrains as it ties in very nicely with Resharper and has some additional features to pull in .pdb:

enter image description here

1
  • 1
    Welcome to Software Recommendations, and thanks for participating! While a good start, unfortunately your post does not contain enough information to be considered a high quality answer. Please read our discussion on what makes an answer high quality to see if you can incorporate some of these improvements into your answer. Especially, you need to point out how your recommended product matches the OPs requirements. Some pointers to stability, reliability, and performance might also be nice ;) Thanks!
    – Izzy
    Commented May 27, 2014 at 14:55
2

The answers here are good for the time the question has been asked. In the meanwhile, IMHO, dnSpy has outperformed them.

  • ✓ Visualize as C# or VB.NET - or IL
  • ✓ Navigation between classes - by Ctrl+Click
  • ✓ Examination of resources - live preview
  • ? Handling .NET since 2.0 - I could not find such an old program for testing :-)
  • ✓ Exporting classes to source files - only the whole project. I could not find it for single classes

It also has other useful features:

  • edit the code directly
  • syntax highlighting
  • debug

I have used dotPeek before, but replaced that by dnSpy 2 years ago and I'm happy.

Above link is the de-facto version, since the formerly dnSpy was archived.

2
  • 1
    Unfortunately that project appears to be archived now. There seems to be an unofficial continuation under the name dnSpyEx.
    – Bob
    Commented Sep 8 at 18:08
  • @Bob: thanks for noticing. I updated the link. Commented Sep 9 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.