Second Life of a Hungarian SharePoint Geek

June 25, 2011

An error occurred while signing: Key not valid for use in specified state

The other day I had to create an Excel 2010 add-in. I wouldn’t have liked to start from scratch, so I took one of my similar projects from the beginning of last year, and started to alter it.

However, when I was to build the project in Visual Studio 2010, I got this error:

An error occurred while signing: Key not valid for use in specified state

I’ve checked the original version of the project, but I found the same error there.

First I thought the issue is with the signing of the assembly, but it turned out to be false. The real reason was related to the pfx certificate  used to sign the manifest for ClickOnce.

The original version of the project was created using a CTP version of Visual Studio 2010 on another machine, so even the certificate was expired.

The following  section contains the related settings in (csproj) file:

<ManifestKeyFile>Former Add-in_TemporaryKey.pfx</ManifestKeyFile>

You can find the same settings on the VS 2010 UI as well, see the Signing /Sign the ClickOnce manifests setting at project properties.


First I tried to simply remove the section from the csproj (after Unload Project, then Edit MyAddInProject.csproj, and Reload Project after editing the file). This helped to remove the build error, but caused error on deployment:

Reference in the deployment does not match the identity defined in the application manifest

So I created a new pfx, and used that certificate for ClickOnce signing.

Later I tried to reproduce the issue that turned out to be not easy, but I think it would have been enough to simply uncheck the Sign the ClickOnce checkbox. At least, VS seems to check it back on project build for me and it solved the issue as well. I’m still not sure what the real reason for this error was, but probably something related to VS was not able to import the certificate to my certificate store, so it could not use it to sign the manifests.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: