Wednesday, November 22, 2006

Compilation Error: ‘The key container name ‘Blah’ does not exist’

I just spent a couple of hours solving this one – when your AssemblyInfo.cs file references a key container (e.g. [assembly: AssemblyKeyName("Blah")]) that doesn’t exist or it doesn’t have sufficient access permissions you’ll get this error.

Fixing this problem used to involve going to the registry entry: HKLM\Software\Microsoft\Cryptography\MachineKeys and setting the permissions to give yourself access to all the keys in the key store – (well you are logged in as Admin after all ;)

The key store has moved from the registry to the file system with Windows 2000 apparently – It’d been a while since I’d been in there as you can tell. You want to go to:
C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

...and change the DACL to give yourself permissions.

In my case, the key container was effectively an orphan – the account that created it must have been deleted and so I had to take ownership of the orphaned file (as admin) and set the DACL up to give myself permissions

As a test for the future I decided to try to access that directory from my Vista box. As I surfed to my Vista ‘C:\Documents and Settings’ folder I was prompted for elevation – I accepted the elevation but the DACL killed the elevation according to the UI – So I checked out the security for the folder and I was marked as having ‘Full Control’ – geez – I hope I don’t ever see this compilation error when I move over to Vista

0 comments: