Question

I have a serious issue, my harddisk crashed yesterday , and i had tons of projects on it .I lost most of them but the ones i recovered are all the debug folders i sent to clients (most of them are desktop applications). I am unable to recover the code for most of the work , but i do have debug folders , my question is is there any way that i can recover my code from them. I am sure some one you would have gone through it in the past, please help if you have any information regarding this.

Files in the debug folder:Example i make application apple

apple.exe                     type=application
apple.pdb                     type=PDBFIle
apple.vshost                  type=Application
apple.vshost.exe.mainfest     type=MANIFEST File

ADDITIONAL INFO:

My laptop hardisk crashed so i am currently using it as a usb drive with another laptop . I had 3 partitions but now i see 4 i,j,k,l . One of them which used to be my D: drive working fine, i see it shows 72 GB free out of 150 GB. Rest of them they are just there no info, when i click them nothing for minutes then it says format drive etc... If you know how to fix that that would be wonderful.

Thank you

Was it helpful?

Solution

You really lucked out with having access to the Debug folders containing your compiled binaries. The fact that you're working in a managed language (C#) means that you can use one of the many .NET decompilers to display the source code that they contain in a readable format. It may not be exactly the same as what you initially typed into Visual Studio, but it will be pretty darn close—way better than can normally be expected in the event of a system crash.

I used to recommend Redgate's .NET Reflector for this task, but they recently decided to eliminate the free version of their decompiler utility and adopted some business practices that I personally disagreed with. Then again, their tools are probably still the best around, so you might consider downloading their 30-day trial to attempt to get your code back. Who knows, you might like it so much that you buy!

If you're a cheapskate like me, or a devotee to truly free software, you can try one of the free alternatives that cropped up after Reflector became not free, like ILSpy, developed by the same people who develop SharpDevelop. Even more alternatives are listed here.

Whichever decompiler utility you choose, download a copy and open its executable. Then from the "File" menu, choose "Open", and navigate to the first compiled .exe from which you want to recover source. The utility will display the name of your application and some metadata about your assembly. From here, you can make sure that you opened the correct file.

In both ILSpy and .NET Reflector, you can click the [+] toggle next to your application's name to expand its listing. You'll see a bunch more expandable items, like References (the DLLs that your application uses), Resources (the resource files compiled into your application), and the namespaces defined in your code. Expanding an individual namespace will show you all of the types defined in that namespace, and expanding a type will show you all of the types, methods, members, etc. defined in that type, and so on down the hierarchy. Clicking on individual items in the source tree to the left will display the decompiled code in the output pane to the right; both ILSpy and .NET Reflector support displaying the code as C#, which should look very readable to you.

For example, using ILSpy to open the ILSpy.exe application itself produces the following output:

 

You really can't break anything in here, so navigate around, exploring and seeing what all can be recovered, amazed at how well this works. Everything works just as well with DLLs as it does with EXEs.

Then get started copying and pasting...

The next order of business is getting your system stable again. If you had a hard disk crash, you definitely don't want to trust that drive ever again! Run out and buy a new one immediately, wipe it, and reload Windows.

Once you finish with that, you definitely want to get on setting up a source/version/revision control system to use in the future to store your code. All smart developers use this for so many reasons. Find more information with a Google search. There are lots of different options. Which one you pick is not important; the important thing is that you pick one!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top