如何在.NET中导入使用sn.exe生成的.snk文件?
我已经使用此命令创建了一个密钥文件:
sn.exe -k 2048 Build.snk
我想使用 .NET 读取此密钥。我找不到任何有关 .snk 格式的文档,所以我想知道 C# 中是否有办法读取 .snk 文件?
我提出这个问题的最初原因是将 .snk 文件用于签名程序集以外的目的。正如下面的答案之一所述,.snk 文件的目的实际上只是用于签署程序集。
I have created a key file with this command:
sn.exe -k 2048 Build.snk
I would like to read in this key with .NET. I haven't been able to find any document as to the format of the .snk, so I'm wondering if there's a way in C# to read in an .snk file?
My original reason for asking the question was to use the .snk file for purposes other than signing an assembly. As one of the answers states below, the purpose of .snk files is really just for signing assemblies.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此处在 MSDN 中找到了提及。这是代码:
Found a mention in MSDN here. Here's the code:
强命名密钥在编译时用于对编译器生成的程序集进行签名,因此在运行时读取它们可能不是您想要的。
首先,在 C# 项目的“属性”窗口中查找“签名”选项卡,您可以在其中选择用于对程序集进行签名的 .snk。
http://msdn.microsoft.com/en-us /library/xc31ft41(VS.100).aspx
Strong naming keys are used at compile-time to sign the assemblies produced by the compiler--so reading them in during runtime probably isn't what you want.
To get started look for the "Signing" tab in your C# Project's Properties window--there you can choose what .snk to sign the assembly with.
http://msdn.microsoft.com/en-us/library/xc31ft41(VS.100).aspx