Exception Printing: An item with the same key has already been added

Exception Printing: An item with the same key has already been added

Forum member · Mar 8, 2010
I am printing off many pdf documents via a Windows services that is running on a server. It works great except occasionlly I get the following error: System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at zz25.ab.b(PrintJob ) at ceTe.DynamicPDF.Printing.PrintJob.Print() I did some checking using .NET Reflector and it seems like the problem is that the JobId within PrintJob class is the same as a previous PrintJob. I am calling PrintJob.Disposable after printing. Is there anything else I need to do? How is JobId being set?(I noticed that it is read-only property)

Re: Exception Printing: An item with the same key has already been added

Support · Mar 12, 2010
The error you are mentioning has been previously reported and the latest build of PrintManager has been verified to resolve it. Please download the latest build of PrintManger and use that to verify that this resolves the problem in your case also. If you already have a serial number for PrintManager then log into the Customer Area, http://www.DynamicPDF.com/CustomerArea to get the latest version. If you are still evaluating then download the latest version from our site, http://www.DynamicPDF.com/Products/DynamicPDFPrintManagerforNET/Download.csp . If you have any additional questions feel free to let us know. Thanks, ceTe Software Support Team

Re: Exception Printing: An item with the same key has already been added

Forum member · Aug 31, 2010
I have downloaded the latest dll's and I am still getting this error. I am running a print operation in parallel, so perhaps the job is unaware of the other threads that are running at the same time assigning jobid's?

Re: Exception Printing: An item with the same key has already been added

Support · Sep 1, 2010
Hello, Can you please send a sample code which can recreate this error at our end to our [^a|mailto:support@cete.com|Support Team^] so that they can look into it further? What exactly you mean by running the print operation in parallel? Thanks, ceTe Software Support Team.

Re: Exception Printing: An item with the same key has already been added

Forum member · Sep 1, 2010
Here is the overview of what I have. Class A has a For...Next loop that spawns new threads based on a given number of items to process. Each item has it's own thread. The loop also creates an instance of Class B. The spawned threads call a method in Class B that creates a new print job and adds items to it. Occasionally, when I get to the job.PrintJob() line in Class B, I get the error described in this post. [Sorry if that doesn't exactly match the concept of parallel processing!] One thing I noticed is that when there is no error, the job jobid is 0. When there is an error, there is a value set in the job jobid. I'm not sure if that means anything or not.

Re: Exception Printing: An item with the same key has already been added

Support · Sep 9, 2010
Hello, We did find the issue and have been fixed it. Actually this is not related to threading issue. The reason for getting this error is, sometimes our product is not throwing any error when some error occurs in printing and this will continue in creating another job. This is causing the "An item with the same key has already been added." error. We have added some functionality to throw proper errors whenever there is a problem and this error contains the error codes also. You can check the reasons for the error using the system error codes. One can get the latest build PrintManager dll by sending a mail to our [^a|mailto:support@cete.com|Support Team^]. The latest build dll will give a proper error messages. Thanks, ceTe Software Support Team.