Search code examples
c#.netmefstrongnamestrong-named-key

Delay signed assemblies chain


I'm developing a C# .NET assembly (name: A.exe) which needs to be delay signed and then fully signed by a third party company. In order to delay sign I use the public key. Assembly A references assemblies B.Core.dll, B.Common.dll, B.Logging.dll which are part of a common library. B-assemblies aren't delay signed, so I use ildasm/ilasm to disassemble them and reassemble delay-signed. I submitted A.exe and B.Core.dll, B.Common.dll, B.Logging.dll and they are now fully signed, however when A starts it complain with error:

Could not load file or assembly 'Assembly B1 PublicKeyToken=null'

The problem shouldn't be related to A.exe since it references delay signed assemblies (they have Strong Name property set to True), but I suspect the culprit is B.Core.
Indeed, B.Core references B.Common and B.Logging, while B.Common and B.Logging are independent each other.
The cause of the error might be that B.Core was initially built using a non-signed B.Common assembly and then disassemble and reassemble all the three assemblies didn't change references... In order to solve the problem, what I was thinking to do is merging all the four assemblies into one single delay signed assembly as a post build step of A. Do you think it will work?
One thing to keep in mind is that B.Core uses .NET MEF to dynamically load exported interfaces from A. Will this process present any issue?

Thanks in advance for your help


Solution

  • I found a solution: I managed to use ILMerge to merge the four assemblies into one, therefore everything worked as expected. Even debug symbols were "merged" into a single PDB file (the trick was to have B.Core.pdb, B.Common.pdb and B.Logging.pdb in the same folder of the respective assemblies).

    MEF did the work without complaining.