It this even possible? Are there any free tools?
4 Answers
Visual Studio for Mac can do the job. Just hit File / Open and then choose the executable or library you want. It'll open the Assembly Browser window.
If you need more detailed code change the Visibility to All members and the Language to C#.
- 231
- 2
- 4
-
but this way doesn't give you the code. Only the signatures of the methods. – Paweł Łukasik Feb 13 '19 at 21:39
-
-
Best free tool for the job is ILSpy, but it runs on Windows. This gives you a limited list of options:
create a windows virtual machine (with virtualbox or vmware player) and run it in there
install WINE on mac, to allow you run .exe files.
get visual studio for mac and use ikdasm
if you feel hardcore, open it in a disassembler ;)
Being an IT guy myself, I would go for the first solution. Check them all out briefly and go for one!
- 256
- 1
- 6
-
2for point 3, there's no tool called ildasm. The tools that are included VS for Mac are called ikdasm or monodis – Paweł Łukasik May 21 '17 at 05:44
-
You can use Jetbrains' Rider. It has a 30 day free trial period.
- Open Rider and open or create a C# project
- Add a dependency to the .exe file (naturally, this also works for .dll).
- In a class in your project, import the package and type the class you want to inspect.
- Do Command+click or Command+B on the class name to trigger Rider's decompile option. Confirm if necessary.
The disadvantage is that we have to repeat step 4 for each class we want to decompile.
- 121
- 2
-
2it looks like you were too fast. Point 4 is incomplete and 5 is missing. – Paweł Łukasik Mar 13 '18 at 08:10
Is this even possible?
Generally yes, with a couple of exceptions:
- Starting with .NET Core and now .NET the
.exefiles produced by the compilation of applications are not CLR assemblies but native assemblies. CLR assemblies contain IL and are decompilable to C# while native assemblies contain machine code and cannot be decompiled to C#.
Hint: in that scenario one should decompile the .dll with the same name. That's the file that contains the compiled C# code.
- Ahead-of-Time compiled
.exefiles are also not CLR assemblies and cannot be decompiled to C#
Are there any free tools?
Yes, there are. One such tool is CodemerxDecompile - the spiritual successor of the popular JustDecompile. While JustDecompile is Windows only, CodemerxDecompile is a multi-platform decompiler that runs on Windows, Linux and MacOS.
Disclosure: I'm part of the team behind CodemerxDecompile.





Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. I may debug the project in the future to find the issue if no easier solution will arise till then. :) – ttt May 15 '17 at 18:43