419

Just to ask if anyone knows of an open source alternative to RedGate's Reflector? I'm interested in checking out how a tool similar to Reflector actually works.

Note, if you know of a free but not open source alternative to Reflector, you can answer the following related question:

Summary - Updated 11th May 2011

A quick round-up of the various open source projects and tools that have been suggested:

  1. Common Compiler Infrastructure (CCI)
  2. Mono Cecil
  3. ILSpy
  4. dnSpy (fork of ILSpy, project appears more active than original)
  5. Dotnet IL Editor (DILE)
  6. IL.View
  7. Monoflector (no longer active as of April 2011)

The following resources may also be of interest:

  • TypeView.cs
  • Jason Haley's notes on disassembling .NET
  • Adrian Bank's recent blog post summarising a number of Reflector alternatives, including several options not mentioned below.
  • Mark Lichtenberg's detailed blog post comparing several of the open source alternatives (DILE, ILSpy and Mono Cecil using MonoDevelop) to Reflector.
Community
  • 1
  • 1
Tangiest
  • 43,737
  • 24
  • 82
  • 113
  • 2
    FYI, there's now a version of v6 that'll be free indefinately: http://eon.businesswire.com/news/eon/20110426007021/en/.NET-Reflector/Reflector/Red-Gate – thecoop Apr 27 '11 at 09:49
  • possible duplicate of [Something Better than .NET Reflector?](http://stackoverflow.com/questions/2646707/something-better-than-net-reflector) – Mat May 26 '12 at 15:44
  • 2
    @Matt, if you check the dates, this question was asked prior to the Something Better than .NET Reflector? question. Also, this question is specifically asking for open source alternatives. – Tangiest May 30 '12 at 14:37

10 Answers10

175

Updated 13th December 2011

The following open source tools are available:

Tangiest
  • 43,737
  • 24
  • 82
  • 113
  • 1
    I used dile a few years ago - it is a great disassembler AND debugger - I highly recommended it back when I was using it. I haven't used it for awhile though. – Jason Haley Mar 11 '10 at 23:49
  • 8
    The current version of ILSpy (ILSpy v1.0.0.440, 20010228) is working like I expected it to be. I can browse methods, properties and even source code for a C# lib without the PDB file. – mathijsuitmegen Mar 02 '11 at 13:08
  • 6
    Just started using ILSpy. Very happy with it so far. Perfect replacemenet. Thank you SharpDevelop! – codemonkey Apr 21 '11 at 09:46
  • 1
    Just came across this tool, very happy to see a replacement for a staple in the .NET developer's tool belt. Some of the decompilations are a little weird (string concatenation shows up as IL would see it, but not necessarily as the code was written - not a bad thing), but overall, a great tool! – CodeMonkey1313 May 03 '11 at 16:03
  • 5
    I just tried ILSpy and it works great! It even reconstructs lambda expressions and iterator ("yield return") methods... wow! I am impressed! – Qwertie May 25 '11 at 16:33
  • ILSpy.....just tried. Works very well :) – Naresh Aug 22 '12 at 07:59
  • From what I can tell, ILSpy doesn't have the "analyze" function that shows "depends on" and "used by" links for an assembly. Is that missing, or am I just not looking in the right place? – JoeCool Sep 26 '12 at 21:04
  • @JoeCool Right click the property/method/etc. and you should see the option. – Stu Pegg Oct 22 '12 at 09:17
  • The reason I dont like ILSpy is that it looks so cluttered, with no line breaks even between methods and fields. dotPeek or JustDecompile looks so easy on eyes. – nawfal Jun 03 '14 at 13:55
37

Another replacement would be dotPeek. JetBrains announced it as a free tool. It will probably have more features when used with their Resharper but even when used alone it works very well.

User experience is more like MSVS than a standalone disassembler. I like code reading more than in Reflector. Ctrl+T navigation suits me better too. Just synchronizing the tree with the code pane could be better.

All in all, it is still in development but very well usable already.

Ferdinand Prantl
  • 5,281
  • 34
  • 35
  • 2
    Great tool, but not open source. It is free, however, which may mean it steals the spotlight from any opensource equivalent. – Drew Noakes Jun 15 '11 at 11:35
  • Ferdinand, -1 for a closed source tool. You should try adding this to one of the linked questions for Reflector. – Tangiest Jun 16 '11 at 11:33
  • 3
    I'm leaving my answer here to make the information more complete. This thread is the easiest to find by google and also the list of other tools here is the most complete. (Not all of them are OSS btw.) – Ferdinand Prantl Jun 21 '11 at 09:34
  • Ferdinand, I have consistently downvoted all answers that give closed source solutions, updated the question text repeatedly to specify that I'm interested in OSS only, and made sure that all solutions in the question summary are open source. There is only one other closed source solution in this question thread, which I have also downvoted. This question was asked before the Redgate decision to charge back earlier this year and specifically asks for open source alternatives. What more do I need to do? – Tangiest Jun 21 '11 at 12:18
  • 9
    @MagicAndi Stop complaining would be a start. I found this thread from Google while looking for a free alternative. I couldn't care less if it's open source or not. @Ferdinand thanks for the dotPeek link, looks promising. – Winston Smith Jun 21 '11 at 15:30
  • @MagicAndi: Editing the question to remove your tirade against closed source and linking to the question where you feel they should be listed instead would be a good start. That will satisfy the "I found this from google" complainers. And saying "A list of closed-source free tools can be found here, but I fear they may not stay free" would be fine, as it explains your rationale for asking specifically for OSS. But don't condemn others willing to use closed source tools. – Ben Voigt Oct 27 '11 at 03:32
  • @WinstonSmith: This is Andi's question, and free-as-in-beer tools are not correct answers to a question asking about free-as-in-freedom alternatives. – Ben Voigt Oct 27 '11 at 03:34
  • Ben, thank you for your contribution. You're probably right about the question intro - I'll update accordingly. But the other relevant questions are already linked by StackOverflow in the Linked and Related sections on the RHS. – Tangiest Oct 27 '11 at 11:25
31

2 options I know of.

  • CCI
  • Mono Cecil

These wont give you C# though.

leppie
  • 115,091
  • 17
  • 196
  • 297
15

Telerik today released a Beta of their own decompilation tool, JustDecompile. Closed source, but free and looks promising.

ray glover
  • 177
  • 1
  • 2
  • Ray, apologies, but to be consistent with the approach to the GrayWolf answer, I'm going to have to downvote this answer. This question is specifically for Open Source alternatives. The .NET community allowed itself to get into this mess by relying on a closed source solution; we should avoid this in the future, regardless of who is providing the tool. -1 – Tangiest May 11 '11 at 08:26
  • Ray, turns out my Kaliro suggestion is also a closed source utility. Please feel free to reciprocate the downvote - I deserve it! Unfortunately, you can't vote on your own answers, either up or down. – Tangiest May 11 '11 at 18:26
  • 1
    @MagicAndi - It would be easier to delete your answer than to downvote it. If you don't feel it adds any value then you have the power to make "be gone". – jpierson Jun 24 '11 at 18:18
  • 1
    Don't remove/downvote this answer. Other SO questions about free alternatives are being closed as "duplicates" of this question by moderators! so the info's worth being here. – Alex from Jitbit Dec 26 '13 at 20:59
  • JustDecompile is a shamefully buggy application that crashes all the time and shows a lot of exceptions where code should be. Apart from that is it very slow. .NET Reflector is MUCH better than that crap! – Elmue Feb 12 '15 at 03:37
12

ILSpy works great!

As far as I can tell it does everything that Reflector did and looks the same too.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Rob
  • 479
  • 8
  • 16
10

Actually, I'm pretty sure Reflector is considered a disassembler with some decompiler functionality. Disassembler because it reads the bytes out of an assembly's file and converts it to an assembly language (ILasm in this case). The Decompiler functionality it provides by parsing the IL into well known patterns (like expressions and statements) which then get translated into higher level languages like C#, VB.Net, etc. The addin api for Reflector allows you to write your own language translator if you wish ... however the magic of how it parses the IL into the expression trees is a closely guarded secret.

I would recommend looking at any of the three things mentioned above if you want to understand how IL disassemblers work: Dile, CCI and Mono are all good sources for this stuff.

I also highly recommend getting the Ecma 335 spec and Serge Lidin's book too.

Jason Haley
  • 3,770
  • 18
  • 22
8

The main reason I used Reflector (and, I think, the main reason most people used it) was for its decompiler: it can translate a method's IL back into source code.

On that count, Monoflector would be the project to watch. It uses Cecil, which does the reflection, and Cecil.Decompiler, which does the decompilation. But Monoflector layers a UI on top of both libraries, which should give you a very good idea of how to use the API.

Monoflector is also a decent alternative to Reflector outright. It lets you browse the types and decompile the methods, which is 99% of what people used Reflector for. It's very rough around the edges, but I'm thinking that will change quickly.

Joe White
  • 94,807
  • 60
  • 220
  • 330
5

Well, Reflector itself is a .NET assembly so you can open Reflector.exe in Reflector to check out how it's built.

Andrew Hare
  • 344,730
  • 71
  • 640
  • 635
  • 14
    No, you can't. Reflector is obfuscated. – Jeff Yates Mar 11 '10 at 15:06
  • Andrew, -1. Reflector has been obfuscated for a number of years, possibly since it's initial release. – Tangiest Mar 11 '10 at 15:06
  • 14
    You can't open Reflector in Reflector? I just did it - obfuscation simply hurts the readability of the IL since identifiers and type names are mangled but that doesn't mean that you cant dissasemble it. – Andrew Hare Mar 11 '10 at 15:08
  • 13
    Andrew - when in a hole, stop digging... – Tangiest Mar 11 '10 at 15:11
  • Well, I think most of us don't speak IL currently... and you can't see the equivalent C# code, it says "// This item is obfuscated and can not be translated." – Thomas Levesque Mar 11 '10 at 15:13
  • 2
    Hmm... I have version 5.1.6.0 and I can see the source just fine - only the identifier names are obfuscated. Not perfect yes, but I am looking at the C# source of Reflector right now. :) – Andrew Hare Mar 11 '10 at 15:16
  • 1
    Andrew, no one is disputing the fact that you can open the Reflector assembly using the Reflector tool. What everyone, apart from yourself, agrees on is that it is unreadable when you do so. – Tangiest Mar 11 '10 at 15:25
  • @MagicAndi - I am not trying to be argumentative, I am just trying to help you by providing a solution to your problem (even though it may not be ideal). – Andrew Hare Mar 11 '10 at 15:27
  • 7
    @Andrew Hare: If you try to look at method implementations via reflector in reflector you will see "This is obfuscated" and it won't show it so no, you can't use Reflector. Besides, being pedantic about what the OP wants with the OP is a losing battle. – Jeff Yates Mar 11 '10 at 17:38
  • 1
    Regardless of the ability to do so, it is probably against some clause in the license. It isn't that it does anything magical, it is that to create a tool that does similar things is hard work, and simply copying the code from or hacking the original tool is probably not going to be a legal option. – Merlyn Morgan-Graham Mar 17 '11 at 21:49
3

I am currently working on an open-source disassembler / decompiler called Assembly Analyzer. It generates source code for methods, displays assembly metadata and resources, and allows you to walk through dependencies.

The project is hosted on CodePlex => http://asmanalyzer.codeplex.com/

1

The Reflector tool uses Reflection.  - apparently this is not correct.

You asked for two things - code that shows what reflector does, and also an alternative to reflector.

Here's an example, much simplified from what Reflector does, but it shows the technique of reflection: TypeView.cs

I don't have a suggestion for an open-source Reflector replacement.

Cheeso
  • 189,189
  • 101
  • 473
  • 713
  • Uhm, if with "Reflection" you refer to "System.Reflection" of the .NET framework, I would very much doubt that. – Christian.K Mar 13 '10 at 12:37
  • 3
    @Christian.K: No, Reflector does not use `System.Reflection` in the framework, Roeder stated as much very early on because of issues with assembly loading and unloading. – casperOne Feb 03 '11 at 22:03
  • @casperOne, I don't know exactly how .NET Reflector works internally, but the `System.Reflection` namespace has been extended since the early days of .NET Reflector. It now supports loading and unloaded assemblies in a reflection-only context: http://stackoverflow.com/questions/225330/how-to-load-a-net-assembly-for-reflection-operations-and-subsequently-unload-it – Drew Noakes Mar 26 '11 at 17:56
  • 1
    @Drew Noakes: This is true, but Roeder never stated (to my knowledge) that he had moved back to Reflection once this change was made. – casperOne Mar 27 '11 at 17:10