How to strongly name a collection so that it has a public key token
I am trying to create a project template wizard. For this 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 below.
I end up with a .pfx file in my assembly. But when I clean and build the dll, there is no public key token on it.
(I checked through run 'sn -t EventWizard.dll' and I got this as output:
Failed to convert key to token. The public key for assembly "(null)" was invalid.
So I don't think I am getting the public key token. How can I get it?
Update: Here is my tab:
source to share
Found a solution in InternalsVisibleTo with Strong-Type assemblers
Go to: C: \ Program Files (x86) \ Microsoft SDK \ Windows \ v8.1A \ bin \ NETFX 4.5.1 Tools (or where sn.exe is always there)
sn -p MyKey.snk MyKey.PublicKeyOnly.snk
This copies the public key to a new file
sn -tp MyKey.PublicKeyOnly.snk
it will display something like this: public key 0024000004800000940000000602000000240000525341310004000001000100cfb8bc23b86a08 e70d021dd53d3b0293e716e71015870bdcc58a0231a4228618851a83e06077f5a44f42beb2baf3 56ad2d344521a96b0081ed0f25f9227523e3625eda524efe1cf2e1e5e41f3693a76ec52347684b 8129a4bb2d5fc49681adf33da0eecc4f81f011af4539d12abe1b4e760b5ce32d766db1012d4402 8381f0b4
Public key token - 2ff2b71993eeff95
Copy the public key value and update the InternalsVisibleTo:
[Assembly: InternalsVisibleTo ( "MyProject.Domain.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100cfb8bc23b86a08 e70d021dd53d3b0293e716e71015870bdcc58a0231a4228618851a83e06077f5a44f42beb2baf3 56ad2d344521a96b0081ed0f25f9227523e3625eda524efe1cf2e1e5e41f3693a76ec52347684b 8129a4bb2d5fc49681adf33da0eecc4f81f011af4539d12abe1b4e760b5ce32d766db1012d4402 8381f0b4")]
source to share