473,796 Members | 2,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"object already exists" exception using RSACryptoServic eProvider

Hello everyone.

I have a small class that encapsulates some functionallity to work with the
RSACryptoServic eProvider. Here is the code of the class i'm using:

public class dsRSA
{
private RSACryptoServic eProvider objRSA = null;

public dsRSA(string keyContainerNam e)
{
CspParameters csp = new CspParameters() ;
csp.Flags = CspProviderFlag s.UseMachineKey Store;
csp.KeyContaine rName = keyContainerNam e;
objRSA = new RSACryptoServic eProvider(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 RSACryptoServic eProvider with the
keyContainerNam e as a parameter passed by my app.. so when execution of the
code reaches the line "objRSA = new RSACryptoServic eProvider(1024, csp);" i
get the following error:

CryptographicEx ception: "object already exists"

StackTrace " en
System.Security .Cryptography.C ryptographicExc eption.ThrowCry ptogaphicExcept ion(Int32
hr)\r\n en System.Security .Cryptography.U tils._CreateCSP (CspParameters
param, Boolean randomKeyContai ner, SafeProvHandle& hProv)\r\n en
System.Security .Cryptography.U tils.CreateProv Handle(CspParam eters parameters,
Boolean randomKeyContai ner)\r\n en
System.Security .Cryptography.U tils.GetKeyPair Helper(CspAlgor ithmType keyType,
CspParameters parameters, Boolean randomKeyContai ner, Int32 dwKeySize,
SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)\ r\n en
System.Security .Cryptography.R SACryptoService Provider.GetKey Pair()\r\n en
System.Security .Cryptography.R SACryptoService Provider..ctor( Int32 dwKeySize,
CspParameters parameters, Boolean useDefaultKeySi ze)\r\n en
System.Security .Cryptography.R SACryptoService Provider..ctor( Int32 dwKeySize,
CspParameters parameters)\r\n en DescaCryp.dsRSA ..ctor(String
keyContainerNam e) en F:\\ProyectosC# \\DescaCryp\\RS A.cs:lÃ*nea 24\r\n en
KeyFileGenerato r.frmKeyGen..ct or() en C:\\Gabriel\\De sca\\ABACUS\\AB ACUS
2.1\\Codigo ABACUS\\KeyFile Generator\\frmK eyGen.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 keyContainerNam e parameter, it works ok... it seems to
be a restriction or something i need to release when the app closes...

Thanks
Feb 5 '07 #1
2 6060
pbx
On Feb 5, 7:10 am, Gabriel Méndez
<GabrielMn...@d iscussions.micr osoft.comwrote:
Hello everyone.

I have a small class that encapsulates some functionallity to work with theRSACryptoSer viceProvider. Here is the code of the class i'm using:

public class dsRSA
{
privateRSACrypt oServiceProvide robjRSA = null;

public dsRSA(string keyContainerNam e)
{
CspParameters csp = new CspParameters() ;
csp.Flags = CspProviderFlag s.UseMachineKey Store;
csp.KeyContaine rName = keyContainerNam e;
objRSA = newRSACryptoSer viceProvider(10 24, 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 deRSACryptoServ iceProviderwith the
keyContainerNam e as a parameter passed by my app.. so when execution of the
code reaches the line "objRSA = newRSACryptoSer viceProvider(10 24, csp);" i
get the following error:

CryptographicEx ception: "objectalreadye xists"

StackTrace " enSystem.Securi ty.Cryptography .CryptographicE xception..Throw CryptogaphicExc ept*ion(Int32
hr)\r\n en System.Security .Cryptography.U tils._CreateCSP (CspParameters
param, Boolean randomKeyContai ner, SafeProvHandle& hProv)\r\n en
System.Security .Cryptography.U tils.CreateProv Handle(CspParam eters parameters,
Boolean randomKeyContai ner)\r\n en
System.Security .Cryptography.U tils.GetKeyPair Helper(CspAlgor ithmType keyType,
CspParameters parameters, Boolean randomKeyContai ner, Int32 dwKeySize,
SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)\ r\n en
System.Security .Cryptography.R SACryptoService Provider.GetKey Pair()\r\n en
System.Security .Cryptography.R SACryptoService Provider..ctor( Int32 dwKeySize,
CspParameters parameters, Boolean useDefaultKeySi ze)\r\n en
System.Security .Cryptography.R SACryptoService Provider..ctor( Int32 dwKeySize,
CspParameters parameters)\r\n en DescaCryp.dsRSA ..ctor(String
keyContainerNam e) en F:\\ProyectosC# \\DescaCryp\\RS A.cs:línea 24\r\n en
KeyFileGenerato r.frmKeyGen..ct or() en C:\\Gabriel\\De sca\\ABACUS\\AB ACUS
2.1\\Codigo ABACUS\\KeyFile Generator\\frmK eyGen.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 keyContainerNam e parameter, it works ok... it seemsto
be a restriction or something i need to release when the app closes...

Thanks
Are you running on Vista? I am having the same problem.

Mar 6 '07 #2
Nop... i'm currently having that error my laptop running Windows XP SP2
--
Ing. Gabriel Méndez
MCP, MCAD
"pbx" wrote:
On Feb 5, 7:10 am, Gabriel Méndez
<GabrielMn...@d iscussions.micr osoft.comwrote:
Hello everyone.

I have a small class that encapsulates some functionallity to work with theRSACryptoSer viceProvider. Here is the code of the class i'm using:

public class dsRSA
{
privateRSACrypt oServiceProvide robjRSA = null;

public dsRSA(string keyContainerNam e)
{
CspParameters csp = new CspParameters() ;
csp.Flags = CspProviderFlag s.UseMachineKey Store;
csp.KeyContaine rName = keyContainerNam e;
objRSA = newRSACryptoSer viceProvider(10 24, 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 deRSACryptoServ iceProviderwith the
keyContainerNam e as a parameter passed by my app.. so when execution of the
code reaches the line "objRSA = newRSACryptoSer viceProvider(10 24, csp);" i
get the following error:

CryptographicEx ception: "objectalreadye xists"

StackTrace " enSystem.Securi ty.Cryptography .CryptographicE xception..Throw CryptogaphicExc eptÂ*ion(Int32
hr)\r\n en System.Security .Cryptography.U tils._CreateCSP (CspParameters
param, Boolean randomKeyContai ner, SafeProvHandle& hProv)\r\n en
System.Security .Cryptography.U tils.CreateProv Handle(CspParam eters parameters,
Boolean randomKeyContai ner)\r\n en
System.Security .Cryptography.U tils.GetKeyPair Helper(CspAlgor ithmType keyType,
CspParameters parameters, Boolean randomKeyContai ner, Int32 dwKeySize,
SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)\ r\n en
System.Security .Cryptography.R SACryptoService Provider.GetKey Pair()\r\n en
System.Security .Cryptography.R SACryptoService Provider..ctor( Int32 dwKeySize,
CspParameters parameters, Boolean useDefaultKeySi ze)\r\n en
System.Security .Cryptography.R SACryptoService Provider..ctor( Int32 dwKeySize,
CspParameters parameters)\r\n en DescaCryp.dsRSA ..ctor(String
keyContainerNam e) en F:\\ProyectosC# \\DescaCryp\\RS A.cs:lÃ*nea 24\r\n en
KeyFileGenerato r.frmKeyGen..ct or() en C:\\Gabriel\\De sca\\ABACUS\\AB ACUS
2.1\\Codigo ABACUS\\KeyFile Generator\\frmK eyGen.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 keyContainerNam e parameter, it works ok... it seems to
be a restriction or something i need to release when the app closes...

Thanks

Are you running on Vista? I am having the same problem.

Mar 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3637
by: David | last post by:
My email application was working a couple of weeks ago, then all of a sudden I get Error Type: (0x8009000F) Object already exists. I checked the permissions on the machinekeys directory like the KB article said it still doesn't work. Does have any ideas?
0
1423
by: JenC | last post by:
Hi, I have a problem when I try to access a DLL I have created. Basically I have an application which uses a number of custom DLLs, I needed to amend one of the DLLs, so I removed the specific Reference from the application, amended and rebuild the DLL and then added the reference back into the application. There was no need to amend the applications code as this was a very minor change. When I run the application I get the following:
1
4729
by: Uttam | last post by:
Hello, How does one suppress the "Object already exists" message when the following statement is executed in ADO? cat.Views.Append "Some_Query", cmd Thanks in advance. Uttam
7
3420
by: (Pete Cresswell) | last post by:
We were testing a version of our app that's been running for months with no problems and it started throwing "Object no longer exists" messages on two machines in the test environment. We tried the same test scenario on a production box: no problems. Tried them on my developer box: no problems. In each of those two cases, the PC's were connected to the same test server and *supposedly* had the same production build image on them. ...
4
3978
by: Liz Patton | last post by:
Here's the exception: System.Exception: Unable to send mail: Could not access 'CDO.Message' object. ---> System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80004005): Unspecified error --- End of inner exception stack trace ---
2
1633
by: prince -=nore=- | last post by:
I have a page, where I'm retrieving a file location from a database and outputting it's contents (HTML) onto a web page. On the aspx page, I have referred to the code behind it using the line below. This is where I'm getting the "Object reference not set to an instance.." error <% response.writefile(thelink())%>. The function that line is referring to is below. The record is being retrieved from the database according to its...
1
9968
by: dwasler | last post by:
Try every thing I know to remove this alias I know there been other posting I read each one none seem to work. Thank You DLWasler dwasler@yahoo.com OS Window db2 V 8.2.X
1
2511
by: atishrg | last post by:
Hello all, I am facing a problem,, that I am not able to trace a "OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT" EXCEPTION .... as I am using On error goto _Lable as soon as this exception occures control directly shifted to error lable I want to excute next line even if this exception occures... Can Any one help to do this Atish
2
4312
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the file. The portion that is not working is the star rating part <?php session_start(); include_once('includes/host_conf.php'); include_once('includes/db_connect.php'); include_once('includes/mysql.lib.php');...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10228
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.