.net 如何比较两个dll的内容?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3315188/
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
How do I compare the contents of two dlls?
提问by Eric
I would like to compare several dlls of one install to several dlls of another install of the application I'm working with. I need to ensure they are exact same. How do I compare two dlls to ensure they have the exact same methods, properties, version, etc?
我想将一个安装的几个 dll 与我正在使用的应用程序的另一个安装的几个 dll 进行比较。我需要确保它们完全相同。如何比较两个 dll 以确保它们具有完全相同的方法、属性、版本等?
I've started to use RedGate .Net Reflector, but the task became tedious so I thought I'd give SO a shot, see if anyone else has been in my situation before and has a quick solution.
我已经开始使用 RedGate .Net Reflector,但任务变得乏味,所以我想我会试一试,看看其他人之前是否遇到过我的情况并且有一个快速的解决方案。
Thank you!
谢谢!
采纳答案by Ken Henderson
I'm assuming that you can't rely on the assembly versioning to answer this.
我假设您不能依靠程序集版本来回答这个问题。
A quick search on googleturned up this post by Scott Hanselmanthat points to several tools that may solve your problem.
在google上快速搜索一下,发现了Scott Hanselman 的这篇文章,其中指出了几个可以解决您问题的工具。
回答by Arturo Molina
回答by C Johnson
Why not use Dependency Walker? Copy all the exported functions into a text file. Repeat the same with the other DLL. Then diff the two text files.
为什么不使用 Dependency Walker?将所有导出的函数复制到文本文件中。对另一个 DLL 重复相同的操作。然后比较两个文本文件。
I did that once to solve error 127, which said it couldn't load the DLL because an 'unknown' dependency was missing.
我这样做是为了解决错误 127,它说它无法加载 DLL,因为缺少“未知”依赖项。
回答by C Johnson
Edit:For non-programmatic determination hints, see confusedGeeks answer :-)
编辑:对于非程序化的确定提示,请参阅confusedGeeks answer :-)
I would use a SN assembly to determine the "version", then;
我会使用 SN 程序集来确定“版本”,然后;
If the ABI is not reflected in the version, perform a secondary md5sum against the files or perform a reflective compare of the two assemblies. The md5sum would of course "catch" internal/compilation changes even if the ABI didn't change. Reflecting the ABI, while more complicated and potentially dog-slow, could determine ABI changes spot-on.
如果 ABI 未反映在版本中,则对文件执行辅助 md5sum 或对两个程序集执行反射比较。即使 ABI 没有改变, md5sum 当然也会“捕捉”内部/编译的变化。反映 ABI 虽然更复杂且可能很慢,但可以确定 ABI 的实时变化。
It might just be easiest and sufficient to just "overwrite" any assembly with the same version (and let previous/later versions remain until removed by whomever put them in place).
仅“覆盖”具有相同版本的任何程序集可能是最简单和足够的(并让先前/更高版本保留,直到被放置它们的人删除)。

