创建强名称托管 (/clr) C++集会
我有一个使用 /clr
开关的托管 C++ 程序集,我尝试按照 这个问题具有以下构建后步骤:
sn -Ra "$(TargetPath)" MyKey.snk
然而,这给出了以下错误:
C:\Path\Assembly.dll does not represent a strongly named assembly
出了什么问题?
I have a managed C++ assembly using the /clr
switch that I am trying to sign as per this question with the following post-build step:
sn -Ra "$(TargetPath)" MyKey.snk
However this is giving the following error:
C:\Path\Assembly.dll does not represent a strongly named assembly
What is going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否在 AssemblyInfo.cpp 中将程序集标记为延迟签名?
Have you marked the assembly for delay signing in AssemblyInfo.cpp?
我最终弄清楚了这一点 - 根据链接的问题,我不能只设置
Linker/Advanced/KeyFile
选项并期望它起作用 - 我需要使用sn.exe 对程序集进行签名,但是我还仍然需要设置
Linker/Advanced/KeyFile
选项。简而言之,要签署 /clr 程序集,您需要执行以下操作:
Linker/Advanced/KeyFile
属性页中指定密钥文件sn.exe
将程序集签名为帖子-build 步骤(我相信使用
[assemble:AssemblyKeyFileAttribute("MyKey.snk")]
相当于在项目属性对话框中设置密钥文件)。I figured this one out in the end - as per the linked question I cannot just set the
Linker/Advanced/KeyFile
option and expect it to work - I need to usesn.exe
to sign the assembly, however I also still need theLinker/Advanced/KeyFile
option to be set.In short to sign a /clr assembly you need to both:
Linker/Advanced/KeyFile
properties pagesn.exe
to sign the assembly as a post-build step(I believe that using the
[assembly:AssemblyKeyFileAttribute("MyKey.snk")]
is equivalent to setting the keyfile in the project properties dialog).标记的答案有助于达成最终解决方案(因此它收到了我的+1)。
然而,我不得不花费几分钟的时间来弄清楚如何在 VS2010 中创建
AssemblyInfo.cpp
。以下是该问题的“更”完整答案。
然后作为构建后步骤,运行
sn -Ra YourAssembly.dll YourAssembly.snk
The marked answer helped to reach the final solution (so it receives a +1 from me).
However had to spent several frustrating minutes figuring out how to create an
AssemblyInfo.cpp
in VS2010.Below is the "more" complete answer to the problem.
Then as a post-build step, run
sn -Ra YourAssembly.dll YourAssembly.snk