Closed maettu-this closed 1 year ago
Exception message if not strongly-named:
Strong'd now
Funny issue, my VS2022 project can deal with the signature, but NUnit (still using 2.x) fails with something like:
System.IO.FileLoadException: The file or assembly "InvertedTomato.Crc, Version=1.3.4.0, Culture=neutral, PublicKeyToken=0329a176645587db" or a dependency cannot be loaded. The strong name signature cannot be verified.
(best-effort translated from German error message)
Your project now uses a 2048-bit key. In case of my computer, sn -k
generates 1024-bit keys. When I compile the library with such key, NUnit works just fine. Googling revealed:
If you do not specify a key size, a 1,024-bit key is generated by default if you have the Microsoft enhanced cryptographic provider installed; otherwise, a 512-bit key is generated.
(https://learn.microsoft.com/en-us/dotnet/framework/tools/sn-exe-strong-name-tool)
Could you specify sn -k 1024
for creating the key? Guess it's no big deal to use such basic key. Other libraries, e.g. OxyPlot and IPNetwork also just use a 1024-bit key.
A 1024-bit key file has a size of 596 bytes, whereas your 2048-bit key file is 1.14 KB in size.
Sounds like your tooling needs to be updated. Maybe NUnit? Downgrading things this end doesn't seem like the correct approach
Well... sure, the upgrade of NUnit already is scheduled at my end. But you for sure are aware that tackling backlog needs time.
But... if Microsoft states "a 1,024-bit key is generated by default" and the stated libraries apparently follow this, I don't really see why not following this.
Rider appears to generate a 2048bit key by default. Feel free to raise a PR to drop this to 1024 if you like. As it's open-source software it's basically meaningless, so I'm happy if you're keen to do the (albeit minor) effort!
@invertedtomato just for your information, in case somebody else runs into the very same issue, even recent versions of NUnit cannot cope with InvertedTomato.Crc
. The length of the key actually wasn't the only cause of the issue, the use of PublicSign
is another. I have raised the NUnit issue 4681 NUnit doesn't seem to be able to deal with PublicSign to eventually get this fixed.
Hi Ben,
In order to include
InvertedTomato.Crc
into libraries or applications that use strong-names,InvertedTomato.Crc
must be signed with a strong name. Please refer to https://learn.microsoft.com/en-us/dotnet/standard/assembly/create-use-strong-named and https://github.com/dotnet/runtime/blob/main/docs/project/strong-name-signing.md.Best regards, Matthias