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
Calling AutoFitColumns
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.
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.
when you are saying “not going to be implemented/supported any time soon.” - are we talking on weeks? months? or even more?
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?
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.
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…
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.
@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)
Since you are not the owner of the thread, so you might not download the attachments shared in this thread. To get “WebApp1.zip”, please create a new thread (please refer to this thread’s attachment (which you want)) and ask for the zipped archive. We will then provide you the attachment in your thread.
Failed ConvertHtmlToPDF_success [4 s]
13:08:10 Error Message:
13:08:10 System.TypeInitializationException : The type initializer for ‘Gdip’ threw an exception.
13:08:10 ----> 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
13:08:10 Stack Trace:
13:08:10 at System.Drawing.SafeNativeMethods.Gdip.GdipCreateMatrix2(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy, IntPtr& matrix)
13:08:10 at #=zA8nUNJDbrXJBRX1YabeyDt2XThIOpPBkig==.#=zQImv8QoE_aK9rThIWirOd48=(SizeF #=zn3pLiPM=)
13:08:10 at #=zA8nUNJDbrXJBRX1YabeyDt2XThIOpPBkig==.#=z2X9sAbY=(SizeF #=zn3pLiPM=)
13:08:10 at #=zTGWPsk3D8hcgYuoVd4ZJFayAmfv92H4LAA==.Render(#=zcA5tkB2Xv5iTqtZ5df5CmVbRvpJB #=zGiPwQn8=)
13:08:10 at #=zdmQGaJtN8uv2uI_l$JUM$cpy4mhYvtmpzw==.#=zCxkQlGtsndLC(#=zeqBIS9hneXY7Njgi8nZUs1A= #=zDr1u$H1kR$pdHKR12Q==, #=zv82HhNzJ2eBZCmpF9Va1MtYXoy5v[] #=zssOFcJiteEa2, #=zcA5tkB2Xv5iTqtZ5df5CmVbRvpJB #=zGiPwQn8=, TimeSpan #=z95GV29I=)