Cannot import the following key file error when importing pfx

code-signingpfx

I researched this question thoroughly on stackoverflow and I have seen numerous answers but none of them have worked for us yet. We recently bought a code signing certificate from comodo that we are going to use to sign our c# WPF .net4 application.
We have followed the instructions on the following URL

and have then imported the certificate in visual studio under 'project properties->singing->sign the assembly'. We then try to build the project and get the following error:

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

We have found numerous solutions on the internet and have tried the following:

  • Click on Change Password and use the same password in all 3 places
  • sn -i [comodo].pfx VS_KEY_xxxxxxxxxxxxx
  • tried converting it to password-less snk file and use that instead of .pfx
  • Tried running visual studio as admin and importing key
  • Tried creating very simple barebones project and signing with that
  • Tried visual studio 2010 as well as 2012
  • We tried adding the following to the assembly [assembly: AssemblyKeyFile("path to key file")]
  • Added event in postbuild "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\signtool.exe" sign /f "$(ProjectDir)[keyfile].pfx" /p [thepassword] /v "$(ProjectDir)obj\Release\$(TargetFileName)"
  • Added in a section in the .csproj file:

  • Downloaded http://visualstudiogallery.msdn.microsoft.com/a83505c6-77b3-44a6-b53b-73d77cba84c8 and clicked 'Apply Fix' on the error

We have had no success thus far. We can import the key just fine using the password so we know the password is correct. We also know that this works fine for signing the manifest in a clickonce publish. Just to make sure we weren't having any other issues, we turned off the cilckonce signing and are just trying to sign the assembly.

Best Answer

You can simply open "Project > Property > Signing" and uncheck the "Sign the ClickOnce manifests" checkbox.