How do I decompile a .NET EXE into readable C# source code?

Viewed 611997

I wrote a C# application for a client a couple of years ago, but I no longer have the source code. All I have is the EXE that I deployed on the client's PC. Is there a way I can generate C# source code from the EXE?

9 Answers

Reflector and its add-in FileDisassembler.

Reflector will allow to see the source code. FileDisassembler will allow you to convert it into a VS solution.

Reflector and the File Disassembler add-in from Denis Bauer. It actually produces source projects from assemblies, where Reflector on its own only displays the disassembled source.

ADDED: My latest favourite is JetBrains' dotPeek.

I'm surprised no one has mentioned dnSpy. dnSpy is a debugger and .NET assembly editor. You can use it to edit and debug assemblies even if you don't have any source code available.

Main features:

  • Debug .NET and Unity assemblies
  • Edit .NET and Unity assemblies
  • Light and dark themes

It is open source and one of most widely used reverse engineering tool for dot net.

There are various .NET / C# Decompilers available nowadays (2022):

  • ILSpy for everyone [free OSS C# IL multi-platforms]
  • dotPeek for convenient decompilation [free C# IL]
  • dnSpy for gurus, security and hackers [free OSS C# VB IL]
  • JustDecompile for everyone [free OSS C# VB IL] (continued as CodemerxDecompile)
  • IldAsm for nostalgia [free IL]
  • .NET Reflector for history [commercial unsupported C# VB IL MC++]

My preference goes to ILSpy because it is free, OSS, very fast (compared to others), so well maintained it is even used by Visual Studio and decompiled code is accurate. This blog post In the Jungle of .NET Decompilers explains in details all these .NET decompilers.

Related