Save Presentation as PPTX error: An entry with the same key already exists

When I create a new presentation and copy the slides of two already existing presentations I receive an “An entry with the sam key already exists.” exception while saving the new presentation as PPTX.

I use the Aspose.Slides .NET, in the Version 17.3.0 everything works fine but in 17.4.0, 17.5.0 and 17.6.0 the exception occurs

This is my code:

        string presDir = @"C:\Data\test\";
        Presentation outputPres = new Presentation();

        for (int i = 1; i <= 2; i++)
        {
            Presentation inputPres = new Presentation(presDir + i + ".pptx");

            foreach(ISlide slide in inputPres.Slides)
                outputPres.Slides.AddClone(slide);
        }

        outputPres.Save(presDir + "output.pptx", SaveFormat.Pptx);

This is the Stack Trace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.SortedList2.Add(TKey key, TValue value) at Aspose.Slides. . ( ) at Aspose.Slides. . (String , , , Byte[] ) at Aspose.Slides. . . ( , ) at Aspose.Slides. . (List1 , , , ​ , )
at Aspose.Slides. . ( , , )
at Aspose.Slides. . (IPresentation )
at Aspose.Slides. . (IPresentation , , PresentationTypeEx , IPptxOptions )
at Aspose.Slides.Presentation. (Stream , PresentationTypeEx , IPptxOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)
at RePpServ.Service.Main(String[] args) in C:\Data\repos git\RePowerPointService\RePowerPointService\Service.cs:line 66
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

@mstusek,

I have worked with source code shared by you using Aspose.Slides for .NET 17.6 and unable to observe the issue. Can you please share environment details with us along with sample presentation so that we may further investigate to help you out.

Best Regards,

Adnan Ahmad

@Adnan.Ahmad

I’m working on Win 7 64Bit, Office 2013, Visual Studio 2015 with dotNET 4.5. Attached you can find the sample files test files.zip (477.5 KB).

Regards,
Michael

@mstusek,

I have worked with shared sample code using Aspose.Slides for .NET 17.6 on my end in a Visual Studio 2015 application and have been able to reproduce the issue. An issue with ID SLIDESNET-39131 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.