Tuesday, May 16, 2017

Cannot import the following key file. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate

I got an error when compiling a project in TeamCity. This particular project had assemblies signed. TeamCity threw an error that said:

Cannot import the following key file. 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_FFA0xxxxx

The fix to this problem is quite simple:

1) Open the Developer Command Prompt for VS 2017
2) Type:

     sn -i "c:\path to your pfx\file.pfx" VS_KEY_xxxxxx

where the VS_KEY is what Team City said

Sunday, April 9, 2017

ASP.NET Identity - Invalid token error

I was generating a code for a user to reset her password. However, this error came up when trying to reset the password. I had 2 problems:

1) The token was being generated in a computer that was not where the token was actually used. I read in SO that the token is tied to a key in the web.config, so either the web.config -keep in mind that ASP.NET has a hierarchy of web.config files, so there's more than 1- needs to match or you need to generate and use the token in the same server.
2) The token contained the plus sign (+). When using it, the server encoded it as a space, so you need to do string.Replace(" ", "+")

Sunday, January 22, 2017

Web deploy error when publishing to azure: String larger than expected

This happened to me while trying to deploy 1 files (a dll) to azure. I couldn't find any answers on SO or other sites. The solution was to deploy all files as opposed to deploying only 1 file