For many years we have kept our strong name key in a key container. Visual Studio doesn't directly support that but, it works fine if you just edit the .csproj file and add:
<KeyContainerName>MyKeyName</KeyContainerName>
We install the key into the key store by doing:
sn -m Y
sn -i MyKeyFile.snk MyKeyName
We can then remove MyKeyFile.snk from that machine and the key is a little more secure.
Recently, this has become a problem after reboots. We suspect the issue was introduced by VS 2015 but, it might be caused by Windows 8 and/or 10. We install the key into the key container and everything works. Then, we reboot that machine and builds fail with:
CSC : error CS7028: Error signing output with public key from container 'MyKeyName' -- Keyset does not exist (Exception from HRESULT: 0x80090016)
It looks like the key container was lost in the reboot but, if we do:
sn -m Y
sn -i MyKeyFile.snk MyKeyName
It fails with:
Failed to install key pair -- Object already exists.
We have to delete the key container with sn -d and then add it back and Visual Studio is happy.
What is going on here? Why can't Visual Studio see our key container after a reboot when sn can see it? Where are key containers actually stored?