5

I've just inherited a web application whose source has long been lost (originally written in 2010 and shelved). The application has a few .dll assemblies that related to the application itself e.g. "applicationCORE.dll", "applicationBI.dll", "applicationDATA.dll" and "application.dll"

I've seen this question and the suggested tool (Just Decompile) is brilliant and created a .sln and .csproj file for the first assembly that I decompiled. My question is how do I merge the various projects that would be created through decompiling with the compiled web application files (.aspx) also, how do I resolve the references in the .aspx files i.e. referencing the codebehind file that no longer exists e.g. "default.aspx" references "default.aspx.cs" while the decompiler creates a "default.cs" file. Is it safer to rename the .cs file or should I update the reference?

Finally, will each dll appear as a separate project within the solution?

I realise this may be perceived as a duplicate question however there doesn't appear to be a resource online that walks a developer through the process.

Daniel
  • 2,167
  • 5
  • 23
  • 44
  • Not sure what you mean by "merge the various projects". As for the framework conventions such as file names, you'd likely have to correct all of that manually. Decompiling a sufficiently complex application into usable source code is a painstaking process, and it's the cost of having lost the source code. And I suspect each DLL would be its own project, I can't imagine any other way to structure that even with the original source code. – David Aug 17 '17 at 14:42
  • Sorry, my terminology may be incorrect, I was referring to merging the web files with the different projects. From your reply, it sounds like I should use the "application.dll" solution file, update the references manually and then add the projects that the other ".dll" files generate (after decompiling) into the solution? I know its painstaking - in your opinion, is it a longer path than rewriting what appears to be a complex application? – Daniel Aug 17 '17 at 14:46
  • I might take the approach of creating an empty shell of an application/solution/etc. as a kind of "controlled environment" and then manually bringing over the decompiled code into that. As for what's a longer path, that's for your organization to determine. Where do they want that path to lead? A duct-tape solution which will probably work for a while? An enterprise application with documentation and testability and support? Somewhere in between? A lot goes into that decision outside of the actual lines of code being written. – David Aug 17 '17 at 14:50
  • Thanks for the advice, I think that approach is smarter than what I had thought. There's sudden pressure to have it running as a proof-of-concept so a duct-tape approach may be worthwhile until there's sufficient buy-in to rewrite. – Daniel Aug 17 '17 at 14:52

1 Answers1

6

Following David's advice, I managed to get the application running from decompiled assemblies. Here's the process I followed to get it working

  1. I had already decompiled the various assemblies into projects using a Reflector (on a trial).
  2. I created a blank Web forms application in Visual Studio
  3. I added the .aspx pages from the website to the project through visual studio
  4. Then added the .cs files from the decompiled 'application.dll' project (since this is the website project within the solution. Some files had to be renamed to match the codebehind references in the `.aspx. files
  5. Each additional project e.g. applicationCore.dll was then added to the solution
  6. Each project's references needed to be updated and references to the newly added projects must be added to the startup project
  7. Since the website was built so long ago, there were 1,000's of syntax errors. The easiest way to resolve them was to use Notepad++ and the Find and Replace. To be safe, I did this file-by-file by following the errors from Visual Studio rather than a batch find and replace
  8. When trying to build I noticed errors where required assemblies were missing so I changed the build output directory of the sub-projects to the bin folder of the web project
  9. I added the connection strings and settings from the original website's web.config. I did this line by line to make sure I didn't break anything and so that I could trace the result of each addition
  10. Finally I had a successful build!

Additional Steps There were also syntax errors which I assumed were due to the decompiling process. Some external references needed to be added and there were slight changes due to the age of the project e.g. asp:AjaxScriptControl changed to asp:ScriptControl (after adding the package using Nuget). I also had to install Crystal Reports for this application and will have to purchase a Telerik licence as there are UI components being used (although I'll see if I can use an open / native alternative as I work through the app).

I've logged in using credentials (I did have to set the correct start page) and tried a few basic CRUD operations. There are silly issues that have to be resolved e.g. the authentication doesn't work properly and there's no redirect if you access a protected page but these things are relatively minor compared to the issues I faced initially.

What I must say is each error was resolved using questions and answers from this site! This was all completed in just under 6 hours.

Daniel
  • 2,167
  • 5
  • 23
  • 44