"object already exists" exception using RSACryptoServiceProvider
- From: Gabriel Méndez <GabrielMndez@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 5 Feb 2007 07:10:03 -0800
Hello everyone.
I have a small class that encapsulates some functionallity to work with the
RSACryptoServiceProvider. Here is the code of the class i'm using:
public class dsRSA
{
private RSACryptoServiceProvider objRSA = null;
public dsRSA(string keyContainerName)
{
CspParameters csp = new CspParameters();
csp.Flags = CspProviderFlags.UseMachineKeyStore;
csp.KeyContainerName = keyContainerName;
objRSA = new RSACryptoServiceProvider(1024, csp);
}
// other code goes here that i'm not using at
this point
}
My app is calling the following code when a winform loads:
private dsRSA _rsa;
_rsa = new dsRSA("ABACUS");
as you can see i'm only instatiating de RSACryptoServiceProvider with the
keyContainerName as a parameter passed by my app.. so when execution of the
code reaches the line "objRSA = new RSACryptoServiceProvider(1024, csp);" i
get the following error:
CryptographicException: "object already exists"
StackTrace " en
System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32
hr)\r\n en System.Security.Cryptography.Utils._CreateCSP(CspParameters
param, Boolean randomKeyContainer, SafeProvHandle& hProv)\r\n en
System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters,
Boolean randomKeyContainer)\r\n en
System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType,
CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize,
SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)\r\n en
System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()\r\n en
System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize,
CspParameters parameters, Boolean useDefaultKeySize)\r\n en
System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize,
CspParameters parameters)\r\n en DescaCryp.dsRSA..ctor(String
keyContainerName) en F:\\ProyectosC#\\DescaCryp\\RSA.cs:línea 24\r\n en
KeyFileGenerator.frmKeyGen..ctor() en C:\\Gabriel\\Desca\\ABACUS\\ABACUS
2.1\\Codigo ABACUS\\KeyFileGenerator\\frmKeyGen.cs:línea 51" string
The app have just worked fine for some time, and is still working on other
machines, but suddenly stopped worked on my developing machine.. Does anyone
know what is causing this execption and how to solve it??
Note: If i change the keyContainerName parameter, it works ok... it seems to
be a restriction or something i need to release when the app closes...
Thanks
.
- Prev by Date: How can I call Activex exe from .NET Web Service
- Next by Date: Re: Modifying an existing Access 2000 database
- Previous by thread: How can I call Activex exe from .NET Web Service
- Next by thread: Re: Modifying an existing Access 2000 database
- Index(es):
Relevant Pages
|