I’m having the same issue as described in several places, including in Stack Overflow question Visual Studio reporting error “PFX – Error Importing Key / Object already exists”.
Most people are having issues on Windows Vista and Windows 7, but in my case I’m running as an administrative user on Windows XP. I’ve tried all of the solutions I’ve found and none have worked so far. Since most of the information I’m finding is a few years old: is there some better/current information and maybe a fix that works more often?
My code signing certificate comes from Go Daddy, and it works fine with the SignTool.exe utility. I’ve signed a lot of EXE files built outside of Visual Studio using SignTool.exe and they all validate correctly.
I tried signing my EXE file for my current project this way, with SignTool.exe, but there appears to be some extra issues related to the ClickOnce publishing I’m trying to use for this project… Hashes are not matching, and ClickOnce is still reporting as “publisher unknown” even though the EXE file is signed.
I still can’t get the IDE option to work, but this worked for me and isn’t too bad:
Enable “Sign the ClickOnce manifests” in the IDE and select “from store” (selecting from PFX file produces the same “object already exists” error).
Do not check “Sign the assembly”.
Add a post build event to run:
So basically using the signtool.exe to sign was the trick, but also the manifest needs to be signed (which I let the IDE do), and the other non-obvious part was that you need to sign the EXE file from the OBJ folder, not the BIN folder.
I like this better than the IDE I guess, because with the IDE I think you have to enter your password every time. This way the password is in the post build event command-line.