引用的组件时,是否可以坚持一个版本号,但忽视了公钥? (即接受符号/无符号)符号、版本号、组件、公钥

2023-09-06 17:09:36 作者:月下凄凉

根据这个问题,

是否可以指定一个引用到另一个组件,需要特定版本,但的没有的坚持一个特定的公钥?我的直觉是没有(因为我被指定版本的猜测时,整个完全限定的程序集名称使用其中既包括版本和PKT)

Is it possible to specify a reference to another assembly, requiring a specific version but not insisting on a specific publickeytoken? My gut feel is no (since I'm guessing when versions are specified, the entire fully qualified assembly name is used which includes both version AND pkt)

所以,如果我有这样的场景:

So if I have this scenario:

a的V1.0(签名) 组件B的1.0版,需要组件A V1.0

v1.0 of Assembly A (unsigned) v1.0 of Assembly B that requires v1.0 of Assembly A

我可以,没有源$ C ​​$ C,重新签署组件(通过反汇编+ ILASM),所以我有急症室的工作版本; B,签约?

Can I, without the source code, re-sign the assemblies (via ildasm + ilasm) so I have working versions of A & B, signed?

推荐答案

所以,这不的非常的回答这个问题,但解决了我潜在的场景,其中移动一对未签名程序集签名的版本,而维持特定版本的要求。事实证明,当你重新签署程序集,ILASM之前,你可以打开.il内,并采取靠近顶部的外观,并添加了特定的公钥的引用,象下面这样:

So this doesn't quite answer the question, but solved my underlying scenario with moving a pair of unsigned assemblies to signed versions while maintaining the specific version requirement. It turns out that when you're re-signing the assemblies, before you ilasm them, you can open up the .il and take a look near the top and add the specific publickeytoken for the references, like below:

// Metadata version: v2.0.50727
.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 2:0:0:0
}
.assembly extern My.Assembly
{
  .publickeytoken = (3E 5D C7 B6 5B C4 C7 0E )                         // .z\V.4..
  .ver 1:0:0:0
}
.assembly extern System.Core
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 3:5:0:0
}

在编译时,一切都应该按预期工作:)

When compiled, everything should work as expected :)