I am running Visual Studio 2012 and writing a backend web service and desktop software in separate solutions. Because the desktop software needs to run elevated ("as administrator"), I need to run the desktop solution in an elevated Visual Studio instance. Both solutions include a signed library project.
When I open the web service solution in a Visual Studio instance without elevating it, I get a build error like
Cannot import the following key file: Redacted.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_Redacted.
When I attempt to fix this by doing that, it fails with an error message saying that the key already exists.
When I attempt to exclude and then re-include the PFX file does not put things right, but makes the "strong name key file" dropdown in Project Properties → Signing blank. Following this, the web service solution builds, but it seems that the library does not get signed since in the (elevated) desktop solution, builds fail with "Assembly generation failed -- Referenced assembly 'redacted' does not have a strong name".
If I try to choose the PFX file again from the dropdown within the web service solution (and reenter the password), I get:
Error importing key
An attempt was made to reference a token that does not exist
Setting the PFX file from the (elevated) desktop solution works, but returns me to square one.
It seems that depending on elevation, Visual Studio looks in different key stores for access to whatever unlocks the PFX. Do I have to run both instances of Visual Studio elevated to work around the problem or can I somehow tell it to look in the same place?