I encountered a very weird scenario with the following code:
CspParameters csp = new CspParameters(1, "Tev CSP v3.0");
csp.KeyNumber = 2;
RSACryptoServiceProvider rsa = new
RSACryptoServiceProvider(csp);
byte[] data = new byte[2];
data[0] = 0;
data[1] = 1;
byte[] sig = rsa.SignData(data, "SHA1");
I m trying to sign a data using a certificate that resides in a smart card.
The above code works perfectly well with .NET framework 1.1. However, when i
compile and run it on .NET framework 2.0, exception was caught when calling
byte[] sig = rsa.SignData(data, "SHA1");
The error is as follow :
An unhandled exception of type
'System.Security.Cryptography.CryptographicException' occurred in
mscorlib.dll
Additional information: The keyset is not defined.
Any idea why this happened ? Thanks.
msnews.microsoft.com - 09 Dec 2006 17:28 GMT
Sorry.. the error message is:
An unhandled exception of type
'System.Security.Cryptography.CryptographicException' occurred in
mscorlib.dll
Additional information: The parameter is incorrect.
>I encountered a very weird scenario with the following code:
>
[quoted text clipped - 23 lines]
>
> Any idea why this happened ? Thanks.