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:

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...