我的应用程序由三个程序集组成:一个引用几个 DLL 的 EXE。这些 DLL 是我的应用程序私有的 - 它们仅由该可执行文件使用。
应该给这些程序集起一个响亮的名字吗?
FxCop 建议他们应该 - 对于目前生产的所有组件:
CA2210:标志<装配>具有强名称键。
但是,此建议说:
一般来说,您应该避免对应用程序 EXE 程序集进行强命名。
和
您可能希望避免使用应用程序私有的强命名组件。
我应该给这些程序集起一个响亮的名字吗?在这种情况下这样做(或不这样做)有什么好处?
编辑:
查看了几个具有类似结构的应用程序,在这个问题上似乎没有达成共识。 Paint.NET 和 Crack.NET 不是强名称,而 的强名称.NET Reflector 和 Snoop 是。
有趣的是,对于 Expression 套件,Microsoft 采用了后一种方法:例如,在 Expression Blend 中,他们选择对 Blend.exe 和随附的 DLL(例如 Microsoft.Expression.Blend.dll)进行强名称签名。
似乎我不太可能收到第一个问题的简单答案:“我应该给这些程序集起一个强名称吗?”。然而,我的第二个问题仍然存在:
在这种情况下,强名称签名二进制文件有什么好处吗?或者说,不这样做有什么好处吗?
编辑 2:
如果没有压倒性的理由选择任何一种方式,我倾向于给我的程序集起一个响亮的名称。因此,我对是否有人可以对此进行扩展(从第一个链接开始)感兴趣:
“强命名会使管理依赖项变得更加困难,并为私有组件增加不必要的开销。”
My application consists of three assemblies: a single EXE which references a couple of DLLs. The DLLs are private to my application - they are used only by this executable.
Should these assemblies be given a strong name?
FxCop suggests that they should - for all of the assemblies it currently produces:
CA2210: Sign <assembly> with a strong name key.
However, this advice says:
In general, you should avoid strong-naming application EXE assemblies.
and
you may want to avoid strong-naming components that are private to your application.
Should I give these assemblies a strong name? What are the benefits of doing so (or not doing so) in this case?
Edit:
Looking at several applications with a similar structure, there seems to be no consensus on this issue. The binaries of Paint.NET and Crack.NET are not strong-named, whereas those of .NET Reflector and Snoop are.
Interestingly, with the Expression suite Microsoft have taken the latter approach: in Expression Blend, for example, they have chosen to strong-name sign both Blend.exe and the accompanying DLLs (such as Microsoft.Expression.Blend.dll).
It seems that I am unlikely to receive a simple answer to my first question: "Should I give these assemblies a strong name?". However, my second question still stands:
Are there any benefits to strong-name signing binaries in this situation? Or, are there any benefits to not doing so?
Edit 2:
If there are no overwhelming reasons to go either way, I am inclined towards giving my assemblies a strong name. I'd thus be interested in whether anyone can expand upon this (from the first link):
"strong-naming can make it more difficult to manage dependencies and add unnecessary overhead for private components."
发布评论
评论(4)
在我看来,在这种情况下强名称签名的好处如下:
签名的缺点(我相信这些是链接文章所指的):
确实令人遗憾的是,选择要么是强命名(因此需要引用来匹配精确的键和精确的版本),要么不是强命名(并且不需要两者匹配)。如果可以需要密钥但不需要特定版本,那么也许可以获得签名的前两个好处,而不会遇到第一个缺点。也许可以通过应用强名称然后使用 app.config 处理版本控制问题来实现?
As I see it, these are the benefits to strong-name signing in this situation:
And the drawbacks to signing (I believe these are what the linked article is referring to):
It does seem a shame that the choice is either strong-naming (and thus requiring references to match an exact key and an exact version), or not strong-naming (and not requiring either to match). If it were possible to require a key but not a particular version, perhaps it would be possible to get the first 2 benefits of signing without also getting the first drawback. Maybe this is possible by applying a strong name and then dealing with the versioning issue using app.config?
强命名程序集仅确保版本兼容性。这与信任议会不同。
换句话说,“强名称”仅指确切的程序集二进制文件与编译时使用的版本号的组合。
如果您对这些程序集进行 GAC,那么 CLR 只会验证它一次。当时大会已开始。这可以提高性能。然而,我的经验表明它是最小的。
强命名的程序集可以替换为非强命名的程序集;这提出了关于强命名不是任何类型的安全功能的部分。
我个人的观点是,与它们相关的疼痛程度并不能证明它们的使用是合理的。痛苦在于他们如何使用自动化测试工具。
https:// web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5054496.html
Strong naming assemblies ONLY ensures version compatibility. This is not the same thing as trusting the assembly.
In other words, the "strong name" ONLY refers to that exact assembly binary in combination with the version number in use at the time of compile.
If you GAC those assemblies, then the CLR will only verify it once. At the time the assembly is gac'd. This can result in a performance improvement. However, my experience has shown it to be minimal.
A strong named assembly can be replaced with one that is not strong named; which brings up the part about strong naming NOT being any type of security feature.
My personal opinion is that the level of pain associated with them does not justify their use. The pain being how they screw with automated testing tools.
https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5054496.html
对程序集进行签名可确保程序集在编译后不会被修改。只要您是唯一的私钥所有者,就没有人能够使用您的密钥退出程序集。
当然,这并不是绝对的保护。黑客可以修改程序集并从所有程序集中删除强名称签名(和引用)。这些组件也可以工作。
但在这种情况下,您可以说修改不是由您进行的。
Signing assemblies ensures that assemblies are not modified after compilation. And as long as you are the only private key owner no one is able to resign the assembly with your key.
Sure, this is not an absolute protection. A hacker can modify assemblies and remove strong name signatures (and references) from all assemblies. These assemblies would also work.
But in such a case you are able to say that the modifications are not made by you.
如果您对程序集进行签名,则任何引用的程序集都会公开公开,它们也必须进行签名。否则,您将有充分的理由得到编译错误。
我认为强命名程序集的主要用途是将其放入 GAC 中。
我认为没有必要对 exe 进行强命名。
只是我的2比索......
If you sign an assembly, any referenced assemblies are publicly exposed they must be signed too. Otherwise you will get a compile error for good reason.
I think the primary use for strong naming an assembly is to get it into the GAC.
I don't see a need to strong name an exe.
just my 2 pesos....