views:

82

answers:

2

Hi,

I have two, third party assemblies:

Foo.dll

and

ReferencesFoo.dll

As noted, ReferencesFoo.dll is an assembly that has a reference to Foo.dll

For my application, I need to resign these assemblies. I use ildasm/ilasm in combination along with a signing key to resign them, however, ReferencesFoo.dll still contains (in it's manifest?) the reference to the Foo.dll old public key and public key token.

So, how do I sign both dll's with my key, and update the references in ReferencesFoo.dll without getting the source code and recompiling?

+2  A: 

You can sign an assembly with the SN.exe tool (using the -R switch to resign an already signed assembly).

But you have to be aware that modifying a third party component might likely be illegal. So make sure there are no legal problems before doing so.

And I'm not aware of any tools to automatically change references. You can find them in the metadatatable #35 which is structured as follows:

  • MajorVersion, MinorVersion, BuildNumber, RevisionNumber (2-byte constants)
  • Flags (a 4-byte bitmask of type AssemblyFlags)
  • PublicKeyOrToken (index into Blob heap – the public key or token that identifies the author of this Assembly)
  • Name (index into String heap)
  • Culture (index into String heap)
  • HashValue (index into Blob heap)
Foxfire
Added explanation of where to find the references to the answer.
Foxfire
+2  A: 

You can easily do that with Mono.Cecil. Open Foo.dll, and save it with your new snk, and update its reference in ReferenceFoo.dll to the appropriate public key token.

Jb Evain