I have a managed C++ assembly using the /clr
switch that I am trying to sign as per this question with the following post-build step:
sn -Ra "$(TargetPath)" MyKey.snk
However this is giving the following error:
C:\Path\Assembly.dll does not represent a strongly named assembly
What is going wrong?
Have you marked the assembly for delay signing in AssemblyInfo.cpp?
[assembly:AssemblyKeyFileAttribute("MyKey.snk")];
[assembly:AssemblyDelaySignAttribute(true)];
I figured this one out in the end - as per the linked question I cannot just set the Linker/Advanced/KeyFile
option and expect it to work - I need to use sn.exe
to sign the assembly, however I also still need the Linker/Advanced/KeyFile
option to be set.
In short to sign a /clr assembly you need to both:
Linker/Advanced/KeyFile
properties pagesn.exe
to sign the assembly as a post-build step(I believe that using the [assembly:AssemblyKeyFileAttribute("MyKey.snk")]
is equivalent to setting the keyfile in the project properties dialog).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With