25 June, 2014

InternalsVisibleTo: PublicKey-extraction

So Microsoft, why does it have to be so unnecessary difficult to setup a InternalVisibleTo attribute on an assembly? Your tooling is really not making it easier, although they are there hidden (sn.exe).

So, to cut to the bone. To extract the full public key and not only the Public Key Token which is kind of a shorthand for the public key, you need to use the sn.exe tool.

1) Open a developer admin command prompt (admin)

2) Type sn.exe –Tp <name of your signed dll> > key.txt (note the  -Tp switch)

3) You will find the public key as well as the token in the text file (key.txt)

In the below the ‘> key.txt’ pipe is not shown, but merely for the purpose of this blog post.

image

4) Insert the value into the assemblyinfo.cs like this:

5) [InternalsVisibleTo(“<assemblyname>, PublicKey=<long number>”)]

Technorati Tags:

No comments:

InRiver: Not loading your extensions?

(You really need to in the loop to appreciate the issue this post addresses). Man, I've been fighting this problem for hours before I ...