编辑 .NET 程序集并重新编译

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13796802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:47:08  来源:igfitidea点击:

Edit .NET assembly and recompile

.netrefactoring.net-assemblydecompiler

提问by Bac Clunky

I'm in a really bad situation. I lost my source code and my customer needs to change a little bit in the application. Think of edit an assembly for an example: Test.dll then add a code line and finally recompile it

我的处境非常糟糕。我丢失了源代码,我的客户需要对应用程序进行一些更改。以编辑程序集为例:Test.dll 然后添加一行代码,最后重新编译

So my question is: - Is it possible to do that? - If it's possible, what is the good tool to edit an assembly and then recompile it?

所以我的问题是: - 有可能这样做吗?- 如果可能的话,编辑程序集然后重新编译它的好工具是什么?

回答by Jacob Stanley

Yes, get ILSpy, it has the ability to save an assembly to disk with a .csproj and everything. This makes it easy to open in Visual Studio and recompile.

是的,获得ILSpy,它能够使用 .csproj 和所有内容将程序集保存到磁盘。这使得在 Visual Studio 中打开和重新编译变得容易。

ILSpy is free and open source.

ILSpy 是免费和开源的。

Save Code

保存代码

回答by Waescher

Exporting & recompiling might not be possible for large applications with many assembies, so I'd suggest a different approach:

对于具有许多程序集的大型应用程序,可能无法导出和重新编译,因此我建议采用不同的方法:

The most comfortable way to go might be to use Reflexilin combination with .NET Reflector(not free) or JustDecompile from Telerik(very free). I did this a few times and had the best result with JustDecompile - even if I'd prefer ILSpyover JustDecompile at any other time.

最舒适的方法可能是将Reflexil.NET Reflector(非免费)或Telerik 的 JustDecompile(非常免费)结合使用。我这样做了几次,并且使用 JustDecompile 获得了最好的结果——即使我在其他任何时候都更喜欢ILSpy 而不是 JustDecompile。

"Now, how"? you might ask:Here's a small tutorial from the guys at Telerik.

“现在怎么办”?您可能会问:这是 Telerik 人员的一个小教程。

(look at the topic "How can I inject C# code in an assembly?")

(查看主题“如何在程序集中注入 C# 代码?”



UPDATE

更新

You should definitely look at the new kid on the block: dnSpy

你绝对应该看看这个街区的新孩子:dnSpy

回答by Remko

Reflectoris the most well known tool for disassembling .net Executables. Another tool is Dis#.

Reflector是最著名的反汇编 .net 可执行文件的工具。另一个工具是Dis#