2
votes

I encounter a little problem with a WPF application. I have a certificate in my store that contains a private key, private key that I'm using to sign XML for a webRequest. This is coded in a different assembly than my WPF application.

When I launch my tests in an admin Visual Studio, I can access private key member of X509Certificate2.

When I launch my tests in a non admin Visual Studio, I can access private key member of X509Certificate2 too.

Everything works fine in VsTestEngine.

But, when I launch my WPF in debug in an admin Visual Studio or not, I cannot access my private key (CryptographicException, keyset is not defined) ? I tried to launch my WPF debug exe in admin mode without Visual Studio, and same result...

Is there a specific option in debugging or in app.config to set to access certificate store ?

Environment : Visual studio 2013, .NET 3.5 (tried with 4.0, 4.5 and 4.5.2), Windows 8.1 pro

Thanks for answers.

1

1 Answers

0
votes

I found the solution.... Really hard to found. I created initialy my projects in .NET 4.5.2, and then, I switch to 4.0 in order to make some tests. After that, impossible to have access to private key in VS. When I switch back to 4.5.2, it doesn't take care of changes !

Creating a new projet in 4.0 still doesn't work, but a new one in 4.5.2 works. So, I had to recreate all my projects in 4.5.2 and don't change frameworks !