Visual Studio 2010 Assembly Signing: An attempt was made to reference a token that does not exist

Running Visual Studio as Administrator fixed this issue for me.


I have the same problem. Just use signtool from the Visual Studio command prompt instead. Sometimes signtool will claim your password is invalid, but usually after a couple of tries it starts working for me.

signtool.exe sign /f YOURCERT.pfx /p YOURPASSWORD YOURTARGET.exe


If you want Visual Studio to automatically sign the files and work with ClickOnce, this is what I had to do:

  • Get a copy of OpenSSL. It is available for Windows. Or use a Linux box as they all pretty much all have it.

  • Run the following to export to a key file:

    openssl pkcs12 -in certfile.pfx -out backupcertfile.key
    
    openssl pkcs12 -export -out certfiletosignwith.pfx -keysig -in backupcertfile.key
    

Then in the project properties you can use the PFX file.