Free Support Forum -

ArgumentOutOfRangeException error on Diagram.Save

I’m encountering ArgumentOutOfRangeException while converting multipage Visio document.
Before you ask - I cannot send you the document , due to security reasons.
Document converts partially - only 2 out of 13 pages fail to convert. I’ve tried converting to several SaveFileFormat (png,jpeg,svg,html,pdf) and it’s always same 2 pages that fail.

Here some code context
var fileName = Path.GetFileNameWithoutExtension(filepath);
var savePath = filepath.Replace(Path.GetFileName(filepath) ?? throw new InvalidOperationException(), “”);
var diagram = new Diagram(filepath);
var pages = diagram.Pages;

            foreach (Page page in pages)
                var pageDiagram = new Diagram();
                var resultPathString = savePath + fileName + "-" + name + ".pdf";
                pageDiagram.Save(resultPathString, SaveFileFormat.PDF);

Here’s error message occures specifically on pageDiagram.Save:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Aspose.Diagram Version

Is there a way to diagnose this on my side? All pages in document look similar , there’s nothing exceptional about those failing ones , at first glance at least


You may please make sure that you are using a valid license before using any method of the API. You can try using 30-days free temporary license in case you do not have one. Furthermore, it is necessary for us to test the scenario in our environment using the same files so that the issue can be addressed accordingly.

In case you cannot share your files publicly, you can send them in a private message by clicking over my username and pressing the Blue Message Button. We will test the scenario in our environment and address it accordingly.

license is valid , works properly on all other files.
I cannot share document as it’s a document I am not authorized to share with third parties.
Is there maybe a loop to works through all shapes to find problem ones?
Any suggestions to find what’s causing failure at all?


We are afraid that we cannot offer any workaround or suggestion without observing the similar issue at our end. The issue may be related to specific Diagram file and it needs to be resolved for it. We assure you that we do not disclose your files with anyone and use them only for testing purposes. Once the issues is fixed, we delete them from our system.

Hello again,
I don’t know why you didn’t recommend to iterate through shapes manually, because it helped me to find problem ones. (17.5 KB)
One of the shapes causes the ArgumentOutOfRangeException and the other one just ends up in wrong place.
Please report back if you will be able to replicate this error on your machines.
Thank you


It was hard to guess if there was some shape which was causing the issue. Nevertheless, we were able to replicate the similar issue at our end as well. A ticket as DIAGRAMNET-52025 has been logged in our issue tracking system for the sake of correction. We will keep you posted with the status of issue resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as DIAGRAMNET-52025) have been fixed in this update. This message was posted using Bugs notification tool by philip.zhou