Resolving errors creating a Strong Name Key

When creating a strong-name key in the “Signing” properties tab of Visual Studio 2005 (aka VS2005 or Whidbey) you may receive a “The operation could not be completed” error message, alternatively using the “sn.exe -k” command-line utility you may receive a “Failed to generate a strong name key pair — Access is denied.” error message.

These errors are usually caused by insufficient permissions to the “%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\RSA\MachineKeys” folder, and will most likely arise when running as a non-administrator user.

To resolve this, you can run the cacls.exe tool as an administrator to grant the required permissions:

cacls.exe “%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\RSA\MachineKeys” /E /G username:F