Using a Common Strong Name (snk) File

So we came across an old problem today which I couldn’t immediately remember the solution to.  As a result, I figured I will blog about it.  it’ll make it easier to come back across later when the same problem comes up again!
 
The first time around, I managed to pull this off the same way, but this time (having forgotten) I found this informative post from Shawn Farkas, as below:
 
Basically, the situation arises when you want to use a common strong name key file (.snk).  The old trick (VS 2003) was to put the following line in your AssemblyInfo file:
[Assembly:AssemblyKeyFile("@\..\File.snk")]
 
However, this has been deprecated in .Net 2.0 and now you will get compiler warnings if you use this method.  Instead, you should do the following (read Shawn’s blog post for the pictures):
 
– Add a link to the shared .snk file to each project (on the project click "Add Existing Item -> <Browse to SNK file> -> Add As Link")
– In the project settings, on the Signing Tab, click "Sign the assembly", then select the newly linked SNK file (should be the first option).
 
This should work fine now, although you probably should put the .snk file somewhere common (like with your solution file) and remember to store it in source control (since it will likely be outside the path of each of your projects.
 
Let me know if you have any troubles..
 
/R
 
 

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.