Getting this error while trying to add clone slide :
Presentation master= new Presentation(this.getClass().getClassLoader().getResourceAsStream("src/main/resources/slide.pptx"));
Presentation presentation = new Presentation();
presentation.getSlides().removeAt(0);
presentation.getSlides().addClone(master.getSlides().get_Item(0));
I am passing the master slide to several methods and executing those methods in parallel. I don’t get any issue when executing them sequentially.
com.aspose.slides.exceptions.InvalidOperationException: Trying to add new cached value with the same keys.
There is issue in your used code. You are cloning the master slide in normal slide with is not right. You need to use the correct slide type for cloning is respecting collection.
I have a static instance of the sourcePPT object, and one instance per thread of the destinationPPT object. And this error happens randomly, not all the time.
@hese2428,
Thank you for the query. Unfortunately, cloning slides is not a safe operation for multi-threaded code. Please take a look at the next article: Multithreading in Aspose.Slides.
@Andrey_Potapov
thanks for the link.
Can I have one sourcePPT Presentation and one destination PPT instance per thread (but within the same java process), so each thread has its own copy of the source Presentation to clone from. Would that cause any issues ?