0

To start off, while I was searching around for answers, I found these:

Reverse Engineering a C# Solution

Are there good tools for C# reverse engineering?

Above url seem like a possible duplicate. I did not find any answers relating to my question around the web so I am asking it here. What I would like to ask is, Can I take a C# solution build generated by Visual Studio 2008 Professional version and generate the source code?

I do not care about UML diagrams like the above questions posted in those url, I want to get source code.

My application is in ASP.NET but I only have a solution build for it, and I need source code which I don't have.

Community
  • 1
  • 1
Bulvak
  • 1,794
  • 8
  • 31
  • 63
  • 1
    how is this question any different? – Mihalis Bagos Jul 09 '12 at 12:15
  • 2
    [dotPeek](http://www.jetbrains.com/decompiler/) is a free decompiler. – Batuu Jul 09 '12 at 12:15
  • @MihalisBagos both of those questions ask for UML diagrams and I specifically listed I dont want UML diagrams. – Bulvak Jul 09 '12 at 12:18
  • 5
    1st url's question: "I would like some advice on how to go about reverse engineering a C# solution into dependency diagrams, sequence diagrams and class diagrams. " Second url's question " I need UML-class-diagrams of my written software and i don't want to draw these diagrams by myself. " Folks, please learn to read the question and details properly before you go on a downvoting spree or +1 spree for those who cannot read. – Bulvak Jul 09 '12 at 12:19
  • The accepted answer in the 2nd question you link to has a tool you can use (".NET reflector"), and comments indicate a plugin is available to generate a project/solution based on the compiled files. That seems to be related to your question. – George Duckett Jul 09 '12 at 12:30
  • @GeorgeDuckett thanks! I didnt know about functionalities of that tool, I assumed that since the question was different the answer must not apply to my scenario. – Bulvak Jul 09 '12 at 12:32

2 Answers2

7

www.reflector.net is great for this.

For example, here is some C# code:

using System;

namespace HW
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Foo Bar");
        }
    }
}

When compiled, Visual Studio generates the following files:

VS

Reflector decompiles the code like this:

Reflector

Like TomTom says, it isn't the same code, but this is still useful to discover how a program works.

Hope this helps

JMK
  • 27,273
  • 52
  • 163
  • 280
6

Can I take a C# solution build generated by Visual Studio 2008 Professional version and generate the source code?

No. You can get a .NET dll (noone cares how it was generated) and have a decompiler generate SOME code if it was not encrypted, but it will not be THE source code.

Stuff like internal variable naming will be different, likely. COmments will be missing. Stuff the compiler optimized out may be different

For example bytes / 1024 / 1024 will be byte / 1048576, as constant expressions are not making it into the DLL.

TomTom
  • 61,059
  • 10
  • 88
  • 148