Home Dashboard Directory Help
Search

Importing key file was canceled. by digitalMoto


Status: 

Closed
 as By Design Help for as By Design


28
0
Sign in
to vote
Type: Bug
ID: 524792
Opened: 1/13/2010 12:18:03 PM
Access Restriction: Public
8
Workaround(s)
view
20
User(s) can reproduce this bug

Description

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).
Details
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>
    <AssemblyOriginatorKeyFile>project_TemporaryKey.pfx</AssemblyOriginatorKeyFile></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.

Thansk,

George

GeorgeTheGISBuilder@yahoo.com
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.

Done.
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?
Thanks,
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.

Thanks,
Richa
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
Sign in to post a workaround.
Posted by ItrelAtPerkins on 9/7/2012 at 4:07 AM
Two actions, outlined independently in previous posts, were required to fix this problem on my rebuilt computer with Windows 8 and VS2012.

sn -i mykey.pfx VS_KEY_xxxxxxxx

right clicking on the .pfx file in Windows Explorer and clicking on "Install PFX"
Posted by Leon van Wyk on 6/19/2012 at 4:09 AM
I am running Windows 7 x64 and solved the issue by right clicking on the .pfx file in Windows Explorer and clicking on "Install PFX"
Posted by serguk on 6/1/2012 at 4:01 PM
this helped me to fix the issue

http://blogs.msdn.com/b/andrekl/archive/2008/01/08/strong-name-signing-in-visual-studio-2005-requires-keyspec-2-at-signature.aspx
Posted by David Klebanoff on 10/8/2010 at 5:05 AM
Sorry Mokosh, VSCommands doesn't fix it. It just trys the "sn -i" solution previously described, which also doesn't work. The only thing that works is running VStudio as an administrator.
Posted by Squared Infinity [Jarek Kardas] on 8/8/2010 at 2:26 AM
VSCommands 2010 (plugin for Visual Studio) can fix this for you automatically - just right-click on error and click Apply Fix from menu. You can get it from visual studio gallery http://visualstudiogallery.msdn.microsoft.com/en-us/d491911d-97f3-4cf6-87b0-6a2882120acf
Posted by veljkoz on 7/8/2010 at 11:59 PM
Go to project properties, signing tab, select "choose from file", choose pfx and you'll get a prompt for password. It worked for me...
Posted by Sergio_FT on 5/25/2010 at 4:48 AM
I had the same problem.

Running the vs 2010 as administrator solved it.
Posted by PeterIbbotson on 5/10/2010 at 10:04 AM
Since no-one else has posted this, here goes. If you use msbuild you'll get this error message

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1970,9): error MSB3325: Cannot import the following key file: mykey.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:
VS_KEY_C0D0ACB5FAE2DFE3 [C:\Source\MyProject.csproj]

This is somewhat cryptic and doesn't actually tell you how to fix the problem. So here for future reference is the answer (obviously change the file name and key to match your error message):

sn -i mykey.pfx VS_KEY_C0D0ACB5FAE2DFE3



File Name Submitted By Submitted On File Size  
CertTest.zip (restricted) 1/13/2010 -