【发布时间】:2017-04-28 05:49:40
【问题描述】:
我有一个未签名的测试应用程序 MyApp,它引用了一个未签名的 DLL MyDll。我最近签署了 MyDll 并想在现场针对 MyApp 对其进行测试,但该应用程序不再运行。我只是通过覆盖 MyDll 来做到这一点。我不想重新编译 MyApp。
Fusion 日志查看器证明问题出在不匹配的公钥上:
LOG: Assembly Name is: MyDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcd1234abcd1234
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
过去,我通过创建配置文件来处理版本不匹配问题,例如MyApp.exe.config,有这样的条目:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<publisherPolicy apply="no" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MyDll" publicKeyToken="abcd1234abcd1234" culture="null" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
在这种特殊情况下,版本号没有改变,但我把它留在那里进行测试。
这显然没有任何改进。 Fuslogvw 确认我的配置文件在我执行 MyApp 时已加载。是否有另一个配置元素要添加到我的配置文件中,以允许我的未签名应用使用已签名的 DLL?
【问题讨论】:
-
这不能用 bindingRedirect 覆盖,必须重建使用 DLL 的应用程序。
-
那真是太糟糕了。 :( 我的印象是未签名的程序集可以使用已签名的程序集。
-
未签名程序集引用已签名程序集,但编译后无法更改签名。这包括签署未签名的程序集(除非您先延迟签署)。
-
如果你能弄乱签名并且一切都会继续愉快地工作 - 签署 dll 的意义何在?
-
很公平,这是有道理的。
标签: c# .net .net-assembly code-signing fusion