无法使用 tlbimp 对导入的 msi.dll 程序集进行签名
这看起来很微不足道,但我无法让它工作。
我有一个 msi.dll 包装器(名为 Interop.WindowsInstaller.dll),我需要对其进行签名。方法是在导入时对其进行签名(这种特定情况甚至记录在 MSDN 中: http://msdn.microsoft.com/en-us/library/zec56a0w.aspx)。
但是 - 无论我如何执行此操作(使用或不使用 oa 密钥文件,使用或不添加“/delaysign”),生成的程序集的大小始终为 36,864 字节,并且在查看 DLL 时属性中没有“数字签名”选项卡(不用说 - DLL 没有签名)。
我在这里缺少什么? (... 帮助!...)
This seems so trivial, yet I can't get it to work..
I have an msi.dll wrapper (named Interop.WindowsInstaller.dll) which I need to sign. The way to do it is by signing it upon import (this specific case is even documented in MSDN: http://msdn.microsoft.com/en-us/library/zec56a0w.aspx).
BUT - no matter how I do it (w/ or w/o a keyfile, w/ or w/o adding "/delaysign"), the generated assemly's size is always 36,864 bytes and when viewing the DLL's properties there is no "Digital Signatures" tab (needless to say - the DLL is NOT signed).
What am I missing here?? (... HELP!...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[注意:最终我得到了 Karel Zikmund 的提示 在此线程上,这帮助我解开了谜团。我将在这里粘贴我的回复 - 为了更大的利益]。
因此,我使用以下行来注册导入程序集:
tlbimp C:\WINDOWS\system32\msi.dll /out:Interop.WindowsInstaller.dll /keyfile:MyKey.snk
然后我将文件复制到适当的位置并构建项目,但每次构建都因以下错误而失败:程序集生成失败 - 引用的程序集“Interop.WindowsInstaller”没有强名称。
我认为问题出在 tlbimp 行,但在阅读 Karel Zikmund 的回复并验证 DLL 是否是强命名(使用 sn -vf Interop.WindowsInstaller)后,我发现了问题。
添加对“Microsoft Windows Installer 对象库”COM 对象的引用实际上将代码块植入到 .csproj 文件中。
我没有意识到,但是这个块导致每次构建项目时都从头开始重新生成 DLL 文件。当然,生成的文件不再是强名称的。
我解决该问题的方法是从项目中删除对“Microsoft Windows Installer 对象库”的引用,并添加对导入(且已签名)Interop.WindowsInstaller 的直接文件引用。 dll 文件。
[Note: Eventually I got a hint from Karel Zikmund on this thread, which helped me solve the mystery. I'll paste my reply here - for the greater good].
So, I used the following line to sign-upon-import the assembly:
tlbimp C:\WINDOWS\system32\msi.dll /out:Interop.WindowsInstaller.dll /keyfile:MyKey.snk
I then copied the file to the appropriate location and built the project, but each time the build failed on the following error: Assembly generation failed -- Referenced assembly 'Interop.WindowsInstaller' does not have a strong name.
I thought the problem was with the tlbimp line, but after reading Karel Zikmund's reply and verifying that the DLL is strong-named (using sn -vf Interop.WindowsInstaller) I found out the problem.
Adding a reference to the "Microsoft Windows Installer Object Library" COM object actually planted a code block into the .csproj file.
I didn't realize it, but this block caused the DLL file to be regenerated from scratch upon each time the project was built. The generated file, of course, was not strong-named anymore.
The way I resolved it was to remove the reference to "Microsoft Windows Installer Object Library" from the project, and add a direct file reference to the imported (and already signed) Interop.WindowsInstaller.dll file.