Use command line option '/keyfile' or appropriate project settings instead of 'AssemblyKeyFile'

Posted by Marcus Hammarberg on November 6, 2006
Ran into an old "friend" compiler error...

This error - actual warning, but if you like i have "all errors as warnings" this will stop you in your steps - will occur in Visual Studio 2005 when you point to a snk-file from the AssemblyInfo-file.

Since this was the way to refer to snk-files in VS2003 this will probably happen to you on your first try. There are a lot of people that has written how to solve this, for example

The solution is to point to the key-file from the properties of the project. However this has to be done by editing the projectfile in a text editor. The article above gives instructions on how to do that.


To do this, following these instructions:

  1. Open the project file (.csproj for C# or .vbproj for VB) in a text editor
  2. Look for the <AssemblyOriginatorKeyFile> attribute within the first element or add it as a child
  3. In between the start and end <AssemblyOriginatorKeyFile> element enter the absolute or relative path to the key file name, ie <AssemblyOriginatorKeyFile>.\..\..\Build\StrongNameKeys\MyKey.snk</AssemblyOriginatorKeyFile>
  4. Save the file and reload the solution/project. You will now notice that Visual Studio happily uses the entered key file name and don't forget to remove the old AssemblyKeyFile attribute


Published by Marcus Hammarberg on Last updated