GDI+ Error Occurs when Adding SVG Image to PowerPoint Presentation in C#

Recently we face with the problem that sometimes we have an exception thrown when adding SVG image to Images collection of Presentation object.
Here is a code sample:

string source = // Loaded svg image from file as a string
var image = new Aspose.Slides.SvgImage(source);
presentation.Images.AddImage(image);

There’s an exception with message “System.Runtime.InteropServices.ExternalException : A generic error occurred in GDI+.” in the third line. It has next stack trace:

at System.Drawing.Imaging.Metafile…ctor(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, String description)
at System.Drawing.Imaging.Metafile…ctor(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type)
at Aspose.Slides.\u000e​ ​.\u0002(Int32 \u0002, Int32 \u0003)
at Aspose.Slides.\u000e​ ​…ctor(\u0002 \u0002, Int32 \u0003, Int32 \u0005)
at Aspose.Slides.\u000f​ ​.\u0002(String \u0002, \u0008 ​ \u0003, Int32 \u0005, Int32 \u0008)
at Aspose.Slides.ImageCollection.AddImage(ISvgImage svgImage)

It doesn’t happen all the time. Only sometimes.
Here’s a svg image:
chart-1-1-svg.zip (2.4 KB)

We use Aspose.Slides for .NET v.21.7.0

@kutensky,
Welcome to our community! Thank you for posting the query. Unfortunately, I have not managed to reproduce the error on my side.

Please try to isolate the problem so that under some conditions the error will recur regularly and share additional information for us.

@Andrey_Potapov It happens only on our CI server (Jenkins) from time to time. We couldn’t reproduce it locally.
I suggest there might be some error related to streams inside Aspose library itself. Because on our side we managed and closed all reading streams, saved it as a string. So I don’t think anything else might wrong on our side.

@kutensky,
Please specify the following:

  • OS version on your server
  • .NET assembly version of Aspose.Slides you are using
  • comprehensive code example including SVG image loading from the file