简体   繁体   English

使用部分源代码反编译C#Exe

[英]Decompile C# Exe with partial source code available

I maintain a C# program at work and due to a hard disk crash i lost a big chunk of code for an already deployed version (which is my own fault for not pushing the git repository often enough) and now i have to make some changes to the program. 我维护着一个C#程序,但由于硬盘崩溃,我为已经部署的版本丢失了一大堆代码(这是我自己的错,因为没有足够频繁地推送git存储库),现在我必须对该程序。 I have the source code of an older version of the program and i want to decompile the exe and merge it with the older source to restore the code i lost. 我有较旧版本的程序的源代码,我想反编译exe并将其与较旧的源合并以恢复丢失的代码。

I know i can decompile with tools like the reflector, but i don't want to merge it with the old code by hand, as i then could just code the changes again (about 1-2 days of work). 我知道我可以使用反射器之类的工具进行反编译,但是我不想用手将其与旧代码合并,因为这样我就可以再次对更改进行编码(大约工作1-2天)。 Is that possible or do i have to go through the code dump manually? 这可能吗,还是我必须手动进行代码转储?

I suggest you recompile the old code, and decompile that with reflector. 我建议您重新编译旧代码,然后使用反射器将其反编译。

Then decompile the current executable with reflector, and diff those two. 然后使用反射器反编译当前的可执行文件,并比较这两个文件。 That way you'll only see the changes you made and you can apply those to your old source code, rather than just taking a diff between decompiled code and the original source - which will obviously throw up huge amounts of uninteresting differences (comments, for one thing!). 这样,您将只会看到所做的更改,并且可以将其应用于旧的源代码,而不仅仅是在反编译的代码与原始源代码之间进行区分-显然会产生大量无趣的差异(注释,对于一件事!)。

I can't see how it would get better than that, to be honest. 老实说,我看不出会有什么比这更好的了。 It will be a manual process of course, but it should still save you some time. 当然,这将是手动过程,但仍应为您节省一些时间。

I had to do this once, I recommend Dis#. 我不得不这样做一次,我建议使用Dis#。

Edit: 编辑:
Now, ILSpy is much better 现在, ILSpy更好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM