1

As per the question,

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:

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

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

Henry C
  • 4,781
  • 4
  • 43
  • 83
  • i saw this question/answer, but it looked a little bit overkill - http://stackoverflow.com/questions/1460271/how-to-use-assembly-binding-redirection-to-ignore-revision-and-build-numbers/2344624#2344624 – Henry C Sep 10 '12 at 06:39

1 Answers1

2

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 :)

Henry C
  • 4,781
  • 4
  • 43
  • 83
  • 1
    Thanks - _just_ what I needed. Had to force a 3rd-party assembly to use my own custom version of an open-source assembly which I had compiled but was unable to sign with the "original" keyfile (and which therefore had a different publicKeyToken). Disassemble, edit the publickeytoken value in the IL, assemble (using a different keyfile, of course, which necessitated going further up the chain and fixing a couple more references similarly) and the magic is done. Useful commands came from @BrutalDev's post on http://stackoverflow.com/questions/7977363/using-unsigned-assemblies-in-signed-ones – mwardm Oct 29 '14 at 14:48