Skip to content

RSACryptoServiceProvider exception

Tom

Asked Feb 6, 2007, 10:13 PM EST2 answers
Share
LinkedInX

Hi,

I've been using the CspParameter class to read/write RSA parameters that is used for encrypting data.

private string Encrypt(string plainText)
{
    try
    {
        CspParameters cp = new CspParameters();
        cp.KeyContainerName = "RSAKeyContainer";
        RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp); <<< exception occurs here
        RSAParameters RSAParams = rsa.ExportParameters(false);
        return RSAEncrypt(plainText, RSAParams, false);
    }
    catch (CryptographicException e)
    {
        return "";
    }
}

The code has been working fine, but recently it started throwing an exception
when I try to instantiate the RSACryptoServiceProvider class. Changing the
KeyContainerName worked for a while, but then the problem came back again.
The error message is "Object already exists". Can anyone explain what's going on ?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    The exception message is "Object already exists".
    0
  • 1 short reply
    • 0
      What's the exception message?
      0