.NET Framework: Re-registering key files for signing assemblies

After reinstalling Visual Studio and trying to resign an assembly with a key, I got the following error:

Cannot import the following key file: .pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name:

To fix open the directory in the Visual Studio command prompt with the pfx file and run the following command:

 sn -i pfxfilename.pfx VS_KEY_EB611118B812345

You only have to run the command once for each unique key.

Source