1

I have a working .NET assembly whose source has been lost.

I would like to recompile with just one method replaced. I have seen this done only by rewriting a class at a time. However this class is huge so that approach is not economically viable. Is there a process that will work for a single method?

Ideally, the process should be fully automated (i.e. something that can be run from an MSYS Makefile) and not involve any GUI (e.g. that of Reflector or ILSpy.)

finnw
  • 47,861
  • 24
  • 143
  • 221
  • Decompile with ILSpy? – spender Nov 14 '13 at 01:54
  • It is indeed possible to use ildasm+ilasm to patch DLLs (i.e. may be needed for some assemblies auto-generated by external tools), but @spender's suggestion (+1) to recover code is likely more useful in long run. – Alexei Levenkov Nov 14 '13 at 02:17

1 Answers1

4

If you download ILSpy, then choose File -> Open, open your .dll file, ensure the assembly is selected in the tree view then choose File -> Save Code, you'll be given the option of saving as a .csproj. Save this into an empty folder and this will decompile the entire assembly and create a VS project, so you can easily recompile the assembly when you're done.

Bridge
  • 29,818
  • 9
  • 60
  • 82
spender
  • 117,338
  • 33
  • 229
  • 351
  • +1 for free option, but you can also spend money on Reflector, which will allow you to debug compiled DLLs inside of Visual Studio (I have used that feature quite a bit to learn/battle with the SharePoint API). ILSpy was created in response to Reflector no longer being free. – Karl Anderson Nov 14 '13 at 02:29
  • Thanks. This (or the equivalent using Reflector) will work, but requires the GUI. Something that will run from the command line would be better. – finnw Nov 14 '13 at 02:42
  • 1
    @finnw I'm mystified by your requirements? How many times are you planning on doing this? – spender Nov 14 '13 at 02:45
  • @spender hundreds. i.e. each time one of the replacement methods is modified. And the upstream version could still change (rare, but if it happens we must respond quickly.) – finnw Nov 14 '13 at 03:49
  • ILSpy cannot translate all VB.NET code to C#. It does quite a good job, but there are a few errors that need to be corrected by hand. – finnw Nov 14 '13 at 04:50