问题
I have a Visual Studio 2008 ClickOnce solution that I am attempting to compile with "Sign Manifest" turned on.
With this option checked, I am prompted for my PFX files password, and upon entering the correct password I receive the error:
"Error Importing Key" / "Object already exists".
I'm sure I've hosed something. I've tried to run the following to no avail.
CERTUTIL -importPFX -user <pfxname>.pfx AT_SIGNATURE
回答1:
I had the same problem. Starting Visual Studio with 'Run as Administrator' solved the issue.
回答2:
I don't know if this will help for this problem, but I had something similar after a Vista to Windows 7 upgrade, and simply had to change permissions on the MachineKeys folder (C:\Documents and Settings\All Users\ApplicationData\Microsoft\Crypto\RSA\ in Windows 7)
See here: Certificate problem - Error Importing Key "object already exists" after Windows 7 upgrade
Let me know if this was helpful :)
回答3:
Another way I just discovered to fix this: Uncheck the "Sign the ClickOnce Manifests", exclude the cert file from the project in the Solution Explorer. Rename the cert file. Doesn't matter what, as long as it's different. Re-enable signing and choose the new file. Enter the password as requested. Build, yay!
回答4:
Just wanted to add my own experience with this problem.
Mine came suddenly after doing a bunch of system-type changes... one of them being switching on Vista UAC to test the app I am working on.
Ran into this exact problem and it wouldn't compile. I'm freaking out...
... fixing the permissions seems on the ...\RSA\MachineKeys folder seems to have made the problem go away but looking at its permissions and noticing that devenv.exe (the VS IDE) was not told to "Run as Administrator" it is possible that this issue may be caused by UAC restrictions.
I hate the pseudo-admin mode in Vista....
回答5:
I too am currently having difficulty with this. My situation is somewhat different to this in that I am attempting to generate a strong-name key file for my assembly
I haven't yet solved the issue but I believe it is caused because, for whatever reason the key already exists in the key store for the CSP used to generate the key. Why the key already exists, I don't know, nor have I found a way to remove it but I will update this question when I do
来源:https://stackoverflow.com/questions/888148/visual-studio-reporting-error-pfx-error-importing-key-object-already-exists