Reputation: 82361
I am trying to create a Project Template Wizard. For that I need a strongly named Assembly with a Public Key token.
I went here: http://msdn.microsoft.com/en-us/library/ms247123.aspx and followed the steps.
I end up with a .pfx file in my assembly. But when I clean and build the dll does not have a Public Key Token on it.
(I verified via running 'sn -t EventWizard.dll' and I got this as a result:
Failed to convert key to token -- The public key for assembly '(null)' was invalid.
So I don't think I am getting a Public Key Token. How can I get one?
Update: Here is my Signing Tab:
Upvotes: 7
Views: 12627
Reputation: 606
I have also faced problems with this.
Solution is very simple - arguments are case sensitive.
//Does not work
sn -t yourassembly.dll
//Works
sn -T yourassembly.dll
Upvotes: 7
Reputation: 217
Found a solution at InternalsVisibleTo with Strong-Type Assemblies
Go to: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools (Or where ever sn.exe is)
sn -p MyKey.snk MyKey.PublicKeyOnly.snk
This copies over the public key to a new file
sn -tp MyKey.PublicKeyOnly.snk
this will output in something like: Public key is 0024000004800000940000000602000000240000525341310004000001000100cfb8bc23b86a08 e70d021dd53d3b0293e716e71015870bdcc58a0231a4228618851a83e06077f5a44f42beb2baf3 56ad2d344521a96b0081ed0f25f9227523e3625eda524efe1cf2e1e5e41f3693a76ec52347684b 8129a4bb2d5fc49681adf33da0eecc4f81f011af4539d12abe1b4e760b5ce32d766db1012d4402 8381f0b4
Public key token is 2ff2b71993eeff95
Copy the public key value and update the InternalsVisibleTo:
[assembly: InternalsVisibleTo("MyProject.Domain.Tests, PublicKey= 0024000004800000940000000602000000240000525341310004000001000100cfb8bc23b86a08 e70d021dd53d3b0293e716e71015870bdcc58a0231a4228618851a83e06077f5a44f42beb2baf3 56ad2d344521a96b0081ed0f25f9227523e3625eda524efe1cf2e1e5e41f3693a76ec52347684b 8129a4bb2d5fc49681adf33da0eecc4f81f011af4539d12abe1b4e760b5ce32d766db1012d4402 8381f0b4")]
Upvotes: 6
Reputation: 311
I also faced with this.
Solution is very simple - arguments are case sensitive.
sn -T <yourassembly.dll>
Upvotes: 31
Reputation: 82361
So it was strongly named after all. But the sn.exe tool needed to be used in a different way to see the value I was looking for (PublicKeyToken).
If I ran this:
sn -e EventWizard.dll temp.txt
sn -t temp.txt
Then it worked just fine.
Upvotes: 8