We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to load shared library 'libgdiplus'

Hi,

We are having an issue on our .NET service (ASP.NET service with .NET Core 6.0 - we create a docker that runs on Azure cloud as a kubernetes pod).

We get the following exception in several scenarios:

---- 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
  1. Calling AutoFitColumns
  2. Initiating Aspose.Slides.Presenation object

Please see how our Docker file is configured: Dockerfile.zip (550 Bytes)

I saw that there are few tickets on this matter, I didn’t find a solution for our issue there. hopefully there is a way to modify our Docker file to fix this matter.

Thanks in advance,
Ori

@orik,

Thanks for the docker file.

I guess some of your test cases would be succeeded which do not involve drawings as they don’t call libgdiplus library. But some cases won’t work which involve drawings or graphics. For example, when you execute “AutoFitColumns” operation, libgdiplus gets called and you got the issue.

We are afraid, to solve your issue thoroughly, there is no better way currently. The reason is Microsoft has stopped support for Libgdiplus on non-Windows platforms. We will develop (new) supported versions for such issues and will eliminate dependencies of System.Drawing.Common and libgdiplus on non-Windows platforms. But since it involves complexities so this is not going to be implemented/supported any time soon.

Please post your issue/query in Aspose.Slides forum, one of our fellow colleagues from Aspose.Slides team will assist you soon there.

Hi @Amjad_Sahi thank you for your quick response.

I have two questions:

  1. when you are saying “not going to be implemented/supported any time soon.” - are we talking on weeks? months? or even more?
  2. Theoretically, if I could run my Docker on windows platform, we are not supposed to have these issues, is this correct?
    Do you have a other recommendation or best practices we should adopt in order to have an instant solution?

Thanks in advance,
Ori

@orik,

  1. We think we have to get rid of Libgdiplus to solve such problems. We decide to use Aspose.Drawing for Aspose.Cells to test and evaluate issues on Linux or non-Windows platforms. Our plan is to implement in sync when the official version of .NET 7 is released by Microsoft.

  2. You know Azure has some special sandbox mechanisms, so we cannot say that solutions that are available on Windows Docker are available in Azure.

Hi orik,
Dealing with the same issue here working in .Net 5 under docker container in Ubuntu 20.04:
A work-around for me was to add a runtimeconfig.template.json file to my project with this content:
{
“configProperties”: {
“System.Drawing.EnableUnixSupport”: true
}
}

This got rid of the TypeInitializationException. Not sure how long this workaround will last though…

gr, Peter

@Amjad_Sahi, @peterdewachtere
Thank you for your answers.

So what we’ll need to understand is what is your suggestion for the short term?
As we understand, .NET 7 will be released only by the end of 2022 and we cannot afford waiting so long.

The two option I see now are

  • Explore windows Dockers solution
  • Move to .NET 5

Do we have other options ?

Please advice.
Thanks !
Ori

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

I am afraid, there is no better option/way to cope with it until .NET7 is released. Anyways, if we found some better way, we will share it with you.

@orik,
We have tested CentOS 7 with .NET Core 6.0 and found no exceptions. The attachment is our test project, which contains a dockfile. You can deploy it for testing. If you can find exceptions, there may be a problem with your platform. If there is no abnormality, please send us the project you found abnormal. It’s best to upload a simple test project. WebApp1.zip (7.6 MB)