Assembly signing changes in VS 2005

Bruce has a post (which I verbatim here) highlighting one of the small changes in Whidbey which will make life easier for a whole bunch of us.

In Whidbey, the name of the .snk file is included as a property on the project and is picked up my msbuild when compiling.  To get to it:

  • Right-click on the project in the solution explorer and select Properties.
  • Click on the Signing tab.
  • Provide the path to the .snk file.

How is it done today? As Bruce reminds us (and I verbatim here) signing assemblies in VS2003 and earlier meant adding attributes to the AssemblyInfo file, something similar to the following.

[assembly: AssemblyKeyFile(“..\\..\\ObjectSharp.snk”)]
[assembly: AssemblyDelaySign(false)]

But there are a couple of issues associated with these attributes.  First, the path to the key file is actually embedded in the assembly.  If you use a full path, it is possible that information about your machine (servers and directories, for example) can be easily extracted by using ildasm.  Not overtly dangerous, but not the best situation.

Also, providing a relative path to the key file is annoying.  I’m sure most of you have dealt with the trial and error of finding exactly where the .snk file is relative to the compilation directory.

Finally, because compilation cleanliness is important to all of us, keeping the AssemblyKeyFile attribute in AssemblyInfo generates a warning message.  Not always critical, but annoying.

Published by

Amit Bahree

This blog is my personal blog and while it does reflect my experiences in my professional life, this is just my thoughts. Most of the entries are technical though sometimes they can vary from the wacky to even political – however that is quite rare. Quite often, I have been asked what’s up with the “gibberish” and the funny title of the blog? Some people even going the extra step to say that, this is a virus that infected their system (ahem) well. [:D] It actually is quite simple, and if you have still not figured out then check out this link – whats in a name?

Leave a Reply

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