Fix: Cannot import the following key file

Here’s another quick fix for a small issue you may encounter when upgrading your project to Visual Studio 2010.  You may find that the import works okay, but when you go to compile, you get the following error message:

Cannot import the following key file: keyfile.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_0123456701234567

The cause of the error is exactly as Visual Studio described: it can’t open the key file it needs to access because the key file is password protected.  The suggested fix, however, is not likely to set you on the right path.  In fact, Visual Studio should really just fix this itself.  In previous versions, it would.  Remember you’d occasionally get a password prompt when opening a project for the first time?

Well, all we need to do to fix this is trigger Visual Studio to ask you for the password.  Then, it will do its thing and you’ll be set.  Try this:

  1. Open Project Properties.
  2. Click on the Signing section.
  3. Where it says ‘Choose a strong name key file:’, reselect the current value from the drop-down box:

  4. Visual Studio will now prompt you for the password.  Enter it.

  5. You might get another error message:

    ”An attempt was made to reference a token that does not exist”

    If so, just ignore it.
  6. Click the ‘Change Password” button:

  7. Enter the original password in all three boxes and click OK. If you’d like to change your password (or if your old password doesn’t meet complexity requirements), you can do so now.
  8. Repeat for each key file in your project.
  9. Save your project and do a rebuild.

Of course, there are less empirical ways of solving this, but they involve using the signtool.exe application and messing around with the certificate store.  This might not be the most impressive way of solving this problem, but it seems to work.


  1. thank you for posting
    By guruprakash

  2. i still get the same error. i had changed pfx password, and rebuild but no good.. :(

  3. I also kept getting the error after doing the above steps. Ended up finding that i could simply right-click on the pfx file and import it that way. It brings up a series of prompts, one of which requests the password. After importing them this way my projects were able to build.

  4. I reselected the Key(pfx) file in the "Choose a Strong Name Key File" drop-down box, Then provided password in the "ENTER PASSWORD" Popup Window. Saved my project and did rebuild.It succeeded. Thanks to all

  5. Mine did not work after the suggested fix. But I noticed the "Create Test Certificate" button in the section above. Pressed that key. It asked for the password (which I had just created) I provided it and had my program back.

    I believe the file in question was simply deleted when I rebuilt my system a few weeks ago (from scratch).

  6. trình học tiếng Anh rất tuyệt vời, nó sẽ làm bạn cảm thấy vui khi học đó là Effortless English.
    lớp học kế toán máy thực hành
    trung tâm kế toán tại thái bình
    trung tâm kế toán tại đà nẵng
    Hôm nay Phượt S+ gợi ý các bạn 1 số điểm du lịch nổi bật để đi trong tháng 3 kèm lịch trình sơ lược để mọi người có thể chủ động đi nhé.


Copyright © 2010 Paul Guenette and Matthew Sleno.