[URL] http://blog.krammesnet.com/2015/03/11/creating-an-snk-for-signing-your-assemblies-with-visual-studio/ [/URL]
[COLOR=#27292B][FONT=Lato]There are a number of reasons you may (or may not) want to sign your assemblies, but if you do, here is a simple way of doing it in Visual Studio.[/FONT][/COLOR]
[LIST]
[*]Create a snk file by opening a Visual Studio command prompt as Administrator <—IMPORTANT ([URL] https://msdn.microsoft.com/en-us/library/ms229859%28v=vs.110%29.aspx [/URL])
[LIST]
[*]sn -k .snk
[/LIST]
[*]Then create a Public Key
[LIST]
[*]sn -p .snk .PublicKey
[/LIST]
[*]Get your Public Key Token
[LIST]
[*]sn -tp .PublicKey
[*]this will output your public key and token to the console, make note of it
[/LIST]
[/LIST]
[COLOR=#27292B][FONT=Lato]Full output from the console will look like this:[/FONT][/COLOR]
[COLOR=#27292B][FONT=Lato][URL=”http://localhost:64079/~/image.axd?picture=image.png”][IMG] [/IMG][/URL][/FONT][/COLOR]
[LIST]
[*]Next, go to the properties of the project containing your assembly you want to sign, and click on the Signing tab.
[*]Check Sign the assembly
[*]Click the dropdown and Browse to the newly created snk file that you created in Step 1
[/LIST]
[COLOR=#27292B][FONT=Lato][URL=”http://localhost:64079/~/image.axd?picture=image_1.png”][IMG] [/IMG][/URL][/FONT][/COLOR]
[COLOR=#27292B][FONT=Lato]The reason you want to note your public key and public key token is for use in your app.config or for InternalsVisibleTo.[/FONT][/COLOR]
[COLOR=#27292B][FONT=Lato]For example, if the assembly you have signed needs to be specified in an InternalsVisibleTo in the assemblyinfo file, you would specify it like this:[/FONT][/COLOR]
[COLOR=#27292B][FONT=Lato][FONT="]
[LIST]
[*][COLOR=#286491][FONT=inherit]<assembly:[/FONT][/COLOR][COLOR=#000000][FONT=inherit] InternalsVisibleTo("MySignedAssemblyName, [/FONT][/COLOR][COLOR=#4DA0D2][FONT=inherit]PublicKey[/FONT][/COLOR][COLOR=#286491][FONT=inherit]=[/FONT][/COLOR][COLOR=#DD1144][FONT=inherit][/FONT][/COLOR][COLOR=#000000][FONT=inherit]0024000004800000940000000602000000240000525341310004000001000100155b8d9138457a0be37b064f4f0fa70ceb948f08a7855122f1d6fe9cb89e74b68d60853358a061482d5e62423881caf1cf276d82b11a2e6075939181ab9e1c3dadfcf23082b04d15fb5f9ca20da5bc99b29f830e5c5d23ae9d3dee6f609d0980ed8ba584f348d48921055e13e66c987f5c5712e15285235cb649f0a1e65c0bb2[/FONT][/COLOR][COLOR=#286491][FONT=inherit][/FONT][/COLOR][COLOR=#000000][FONT=inherit]”) />[/FONT][/COLOR]
[/LIST]
[/FONT]
Or, if you were referencing the assembly in your app.config for a custom Logging handler using Enterprise Library, it would look like this:
[/FONT][/COLOR]
[COLOR=#27292B][FONT=Lato][/FONT][/COLOR][COLOR=#27292B][FONT=Lato][FONT="]
[LIST]
[*][COLOR=#286491][FONT=inherit][/FONT][/COLOR][COLOR=#000000][FONT=inherit][/FONT][/COLOR]
[*][COLOR=#000000][FONT=inherit] [/FONT][/COLOR][COLOR=#286491][FONT=inherit][/FONT][/COLOR][COLOR=#000000][FONT=inherit][/FONT][/COLOR]
[*][COLOR=#000000][FONT=inherit] [/FONT][/COLOR][COLOR=#286491][FONT=inherit][/FONT][/COLOR][COLOR=#000000][FONT=inherit][/FONT][/COLOR]
[*][COLOR=#000000][FONT=inherit] [/FONT][/COLOR][COLOR=#286491][FONT=inherit]<add[/FONT][/COLOR][COLOR=#000000][FONT=inherit][/FONT][/COLOR]
[*][COLOR=#000000][FONT=inherit] [/FONT][/COLOR][COLOR=#4DA0D2][FONT=inherit]type[/FONT][/COLOR][COLOR=#286491][FONT=inherit]=[/FONT][/COLOR][COLOR=#DD1144][FONT=inherit]"MyCustomLogExceptionHandlerClassName, MySignedCustomLogHandlerAssemblyName, Culture=neutral, PublicKeyToken=[/FONT][/COLOR][COLOR=#000000][FONT=inherit]0b4def2ce7bdd21a[/FONT][/COLOR][COLOR=#286491][FONT=inherit][/FONT][/COLOR][COLOR=#000000][FONT=inherit]”[/FONT][/COLOR]
[*][COLOR=#000000][FONT=inherit] name=”LogExceptionHandler” />[/FONT][/COLOR]
[*][COLOR=#000000][FONT=inherit] [/FONT][/COLOR][COLOR=#286491][FONT=inherit][/FONT][/COLOR][COLOR=#000000][FONT=inherit][/FONT][/COLOR]
[*][COLOR=#000000][FONT=inherit] [/FONT][/COLOR][COLOR=#286491][FONT=inherit][/FONT][/COLOR][COLOR=#000000][FONT=inherit][/FONT][/COLOR]
[*][COLOR=#000000][FONT=inherit][/FONT][/COLOR][COLOR=#286491][FONT=inherit][/FONT][/COLOR]
[/LIST]
[/FONT]
[/FONT][/COLOR]