Unable to Load Shared Library ‘libgdiplus’ Using Aspose.Slides for .NET


Please see my ticket here - Unable to load shared library 'libgdiplus'
The issue we have with libgdiplus seems to affect initialization of Presentation objects in the Docker environment.
This is the error we are getting:

  Error Message:
   Aspose.Slides.PptxReadException : The type initializer for 'Gdip' threw an 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
  Stack Trace:
     at ​ ​.(Presentation , Stream , InterruptionToken )
   at Aspose.Slides.Presentation.(Stream , Boolean )
   at Aspose.Slides.Presentation.(Stream , Boolean )
   at Aspose.Slides.Presentation.(String , Boolean )
   at Aspose.Slides.Presentation.(String )
   at Aspose.Slides.Presentation..ctor(String file)
   at DRNetService.Operations.SvgExtractor.Do(String fileName) in /src/DRNetService/DRNetService/DRNetService/DRNetService/Operations/SvgExtractor.cs:line 64
   at DRNetService.Controllers.CalculationController.GetSVG(String fileName, String userName, String userId, String documentId, String documentVersionId) in /src/DRNetService/DRNetService/DRNetService/DRNetService/Controllers/CalculationController.cs:line 259
   at DRNetService.Controllers.CalculationController.GetSVGv2(String fileOrPath, Boolean decrypt, String userName, String userId, String documentId, String documentVersionId) in /src/DRNetService/DRNetService/DRNetService/DRNetService/Controllers/CalculationController.cs:line 278
   at TestDRNetService.TestSvg.TestSvgFile() in /src/DRNetService/DRNetService/TestDRNetService/TestSvg.cs:line 19
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)

I was told to open another ticket here.
Any advice?


Thank you for contacting support.

The error you are experiencing related to .NET 6. Unfortunately, Aspose.Slides does not support .NET 6 yet. I’ve linked this forum thread to an appropriate task with ID SLIDESNET-42778 in our issue tracking system. You will be notified when the issue is resolved.

.NET 6 support has been planed for Aspose.Slides 22.6. This release will be published in the second half of June.

@Andrey_Potapov - thanks for you response and information

Is this issue is related to .NET 6?
If we move to .NET 5 we’ll not encounter it?

I reviewed your docker file and saw that it includes installing libgdiplus library. If the library is installed, the lack of .NET 6 support may cause such errors.

Aspose.Slides works fine with .NET 5, please try to use it. If the issue persists, please confirm it.

Hi @Andrey_Potapov
I’ve tried migrating the service to .NET 5 and this didn’t resolve the issue, I’m getting the same errors

Any advice?


Please check your results using the latest version of Aspose.Slides if it is possible. If the issue persists, please share the following data and information:

  • input presentation file
  • code example that reproduces the error
  • Aspose.Slides version you used

Hi @Andrey_Potapov

Please find attached the presentation we are using FontsTest.zip (152.9 KB)

We are using Aspose slides version 22.4.0

The code is very simple
We get the error when initializing new presentation object

        _presentation = new Presentation(fileName);


Thank you for the additional information. I added a ticket with ID SLIDESNET-43176 to our issue tracking system. Our development team will investigate this case. We will inform you of any progress.

Our developers have investigated the issue. Please try using the following dockerfile example.

FROM mcr.microsoft.com/dotnet/runtime:5.0-alpine3.15 AS base
RUN apk update
RUN apk --no-cache add fontconfig
RUN apk add libgdiplus --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
RUN apk --no-cache add msttcorefonts-installer fontconfig freetype-dev libjpeg-turbo-dev libpng-dev tesseract-ocr && \
update-ms-fonts && \
fc-cache -f
RUN apk add --no-cache icu-libs

FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine3.15 AS build

COPY ["SLIDESNET_43176/SLIDESNET_43176.csproj", "SLIDESNET_43176/"]
RUN dotnet restore "SLIDESNET_43176/SLIDESNET_43176.csproj"
COPY . .
RUN dotnet build "SLIDESNET_43176.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "SLIDESNET_43176.csproj" -c Release -o /app/publish

FROM base AS final
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SLIDESNET_43176.dll"]

Hi @Andrey_Potapov
Thank you for your replay.

Can you please direct me to the specific lines in the docker file that actually resolve the issue?

I cannot use it as is :slight_smile:


I’ve passed your request on to our developers. We will let you know it soon.

Unfortunately, our developers did not point out the specific lines in the docker file you requested. Please try using the project in Worked_net5.zip (155.5 KB), place Aspose.Slides.dll in the SLIDESNET_43176\Libs before. If the example does not help you, please share a sample project that reproduces the problem.

The issues you found earlier (filed as SLIDESNET-42778) have been fixed in Aspose.Slides for .NET 23.2 (ZIP, MSI).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.