简体   繁体   中英

The type initializer for 'Gdip' threw an exception

I am deploying my ASP.Net Core Web API using Heroku and this error occurs when calling Image.FromStream(memoryStream) function:

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

Even though using RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev in Docker file, this error still occurs in Heroku only (it doesn't occur in localhost).

Can anyone help me for the solution? I'm doing my capstone project so very appreciate getting your help.

I found the way to fix that.Net 6 in Linux (which OS heroku is using to deploy) doesn't support System.Drawing library anymore. So I decided to change the System.Drawing library by ImageSharp library. You can find the information here for changes: https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM