Aspose.Slides.Presentation Throws “The Type Initializer for ‘Gdip’ Threw Exception”

I was redirected to this subforum from Aspose.PDF, where similar problem took place, but was solved by linking another library (Aspose.PDF.Document throws "The type initializer for 'Gdip' threw exception"). But now we need solution for Slides.

While trying to generate PDF with PPT we get the exception:
The type initializer for ‘Gdip’ threw exception

var loadOptions = new Aspose.Slides.LoadOptions();
loadOptions.LoadFormat = LoadFormat.Ppt;
var presentation = new Aspose.Slides.Presentation(filePath, loadOptions);
presentation.Save (newPath, Aspose.Slides.Export.SaveFormat.Pdf); // <-- error "Gdip" line

On windows that code works perfectly. Supposedly, error occurs because of “System.Drawing” usage, instead of Aspose.Drawing in Slides.

Need help and/or workaround.

Aspose.Slides 22.12.0
.NET 6.0
OS: Ubuntu 20.04

@SergTomcat,
Thank you for describing the issue. Please share the following additional data:

  • simple project that reproduces the error
  • full stack trace of the error

@Andrey_Potapov, here is the sample project:
https://websoft365-my.sharepoint.com/:u:/g/personal/kotoff_websoft_ru/EXTW-CzUlcZGo5GkbJOoUBABAJE9MXRSJusJkq_aqkX6iw?e=bbR6dh

Code in “\ConsoleApp1\ConsoleApp1\Program.cs”
Builded executable for Linux in “\ConsoleApp1\ConsoleApp1\bin\Debug\net6.0\ubuntu.16.04-x64\ConsoleApp1”

Full stack trace:

wt@ubuntu1604docker:~/temp/ubuntu.16.04-x64$ ./ConsoleApp1
./ConsoleApp1
Unhandled exception. System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception.
—> System.DllNotFoundException: Unable to load shared library ‘libgdiplus’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip…cctor()
— End of inner exception stack trace —
at System.Drawing.SafeNativeMethods.Gdip.GdipStringFormatGetGenericTypographic(IntPtr& format)
at System.Drawing.StringFormat.get_GenericTypographic()
at tor(Bitmap )
at …ctor(Int32 , Int32 , Single , Single, Boolean , Boolean , , List1 ) at Aspose.Slides.Slide.(Boolean , ,ist1, InterruptionToken )
atresentation , Stream , Int32[] , PdfOptions, InterruptionToken )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)
at Program.$(String[] args) in C:\Projects\ConsoleApp1\ConsoleApp1\Program.cs:line 11
Aborted (core dumped)

Looking forward for a solution, as time is running out.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-43747

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Any update on SLIDESNET-43747? I am facing similar issue on latest version of Aspose slide.

@prorigo,
The issue is still open. Unfortunately, I don’t have any additional information yet.

We are getting the same error in our Docker image on LINUX. It works great on our local Windows box in the same container. What is an ETA for it to be fixed?

Thank You,
Chad
Alludo

@ChadAll

We are afraid that the earlier logged ticket hasn’t been yet resolved. We have recorded your concerns and will surely update you via this forum thread once ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

@SergTomcat,
Our developers have investigated the case. The exception occurs because the libgdiplus library is missing, which is required by older versions of System.Drawing.Common in Linux environments. To install libgdiplus on WSL with Ubuntu 20.04, execute the following command in the terminal:

sudo apt update && sudo apt install -y libgdiplus

To install libgdiplus in Docker, add the following script to your Dockerfile:

RUN apt-get update && apt-get install -y libgdiplus