Importing key file was canceled. - by digitalMoto

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 524792 Comments
Status Closed Workarounds
Type Bug Repros 20
Opened 1/13/2010 12:18:03 PM
Access Restriction Public


I usually migrate code between 3 or 4 different computers during a development cycle.  Last night I pulled a project off of my development machine and loaded it up on my netbook.  Then I get a series of errors reloated to loading the certificate.  

It used to be that when I'd migrate code, I was get a password prompt related to openning the pfx file on the first build.  That no longer happens.  VS starts throwing errors.  The work around I used last night was to remove all of the certs (5 projects in the solution), recompile, then add them back in.  Lame and a waste of time.  I was messing about with the IDE instead of writing code.

I'm attaching a very small solution.  This blows up if I move machines.  The certificate password is 'password'.  

All machines in my environment are Win7 Enterprise.  My main development machine is x64 all others are x86 (2 laptops, 3 workstations).
Sign in to post a comment.
Posted by Ismael Zori on 3/15/2012 at 2:40 AM
I´ve found a workaround:

1) Uncheck 'Sign the assembly' (Project properties > Signing).
2) Remove pfx file from project.
3) Edit vbproj file (project file) using an editor (like notepad). Find and remove all references to file pfx ('<PropertyGroup>
4) Rebuild project in VS 2010.
Posted by Alexander Yaremchuk on 12/21/2011 at 11:56 PM
George's solution works for us, but it is painful to do so each time on different machines.
Posted by George Pan1 on 12/6/2010 at 1:14 PM
Please let me know if you have any further issues.


Posted by George Pan1 on 12/6/2010 at 1:12 PM
Here is the simple way to do it in VS 2010: Project -> Property -> Signing ->Dropdown box -> new ->Use the same name.pfx file to replace the existing one.

Posted by _Aleks on 12/4/2010 at 8:27 AM
None of these ways work for me.

It seems that this problem was reported about a year ago, but MS still has no real solution. Too bad!
Posted by MikeGCompass on 11/16/2010 at 6:06 AM
Oh one other interesting point in that on one developer machine where it doesn't work, there is a solution that has 2 projects (One class library, one windows forms exe) one project does build OK and sign correctly, the other doesn't. Although the same pfx file is used in both cases.
We have tried removing the pfx files and adding them back in and the same applies, the windows forms project will still not build.

This is the VB error message which as you can see has no reference to the container name (so I can't try out the sn.exe workaround)
Error     5             Cannot import the following key file: CCC.pfx. The key file may be password protected. To correct this, try to import the certificate again or import the certificate manually into the current user’s personal certificate store.                
Posted by MikeGCompass on 11/16/2010 at 5:33 AM
The equivalent error message for a vbproj doesn't even include the key container name so half the workarounds mentioned in this post (and elsewhere) do not apply.
Please could the VB team also be made aware of this. THis is causing us headaches for our development. Half our developers are unable to get around this issue and we have therefore had to turn off signing for all projects where this error has occured. Is there any news on whether and when this is going to be fixed?
Can anyone tell me how you find the key container name, in the meantime?
Mike G
Posted by KJohnstone on 9/27/2010 at 5:04 AM
This is a vital and urgent issue for our company. We have a solution with a large number of projects, all of which experience this issue when we check in the key files from one machine and 'Get Latest' on them on another. None of the 4 workarounds work or are effective.
Posted by ward0093 on 9/3/2010 at 6:59 AM
I have the same issue... i can use the work around but it changes constantly and for some reason my Assemblies that are referencing the assemblies w/ COM wouldn't build either.

I use Click Once and right now I'M STUCK!... i can't upgrade to VS 2010 (stuck with VS 2008) until this is fixed and fully tested!

I need to know a date when the patch will be release to fix this... so i can notify my team when we will be doing the upgrade???
Posted by LuigiC2750157 on 9/3/2010 at 2:40 AM
Same Problem, Importing correctly, but when I'm going to build I get the message.
I tried all the Workaround but no joy.
Any Idea?

Posted by figuerres on 8/30/2010 at 11:32 AM
This is a REAL pain.... I have an app that gets deployed to over 200 desktops and if a chnage inn the key breaks the clickonce install we will have a bunch of upset customers calling us for hours till the software is working again...

Posted by Fusion777 on 3/9/2010 at 2:22 PM
I too am experiencing this issue. A quicker (but still unpleasant) workaround to removing/readding the certs is to go into your properties for the affected project(s) and change the cert's password. You can change it to its original password if you desire (i.e. old password="password" new password="password"). Then VS2010 will click into recognizing the cert. The caveats:

1. Your cert files get touched & changed. If you keep a copy around and revert them, even with the same password, it won't build. I verified that it does *not* break VS2008 compatibility
2. This only works per machine/login, so this isn't effective for multi-developer/multi-machine. If you're doing this only on one PC then it works
Posted by Microsoft on 2/3/2010 at 5:45 PM
Thank you for your feedback. In VS2010, MSBuild has removed all dependencies from Systems.Windows.Forms and this is causing the error you are seeing. The workaround for this is to use CryptoStore providers.

Posted by ACushen on 1/14/2010 at 1:12 PM
I am now experiencing this in VS 2008 Pro. Last night, a Windows Update re-started my Vista laptop while I was away from it. This morning, after a re-boot, when I attempt to build the project, I get an "Import key file" dialog, asking me to import a Key file that is already in the project. When I enter the password for the key, I get a messagebox that says:

Error importing key
Object already exists

Then, I get an error for the build that says "Importing key file "MyKey.pfx" was canceled." Removing the key file, building, then adding it back causes the same problem, as does doing this after Cleaning the project.

UPDATE: I have just closed and re-opened Visual Studio, and the error appears to have gone away for the moment. If I see it again, I will comment again.
Posted by Microsoft on 1/13/2010 at 9:48 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Thank you