Linux App Service - 'System.Drawing.GDIPlus' threw an exception. Unable to load shared library 'gdiplus' or one of its dependencies

Marcos Vinicius dos Santos 1 Reputation point
2020-04-03T11:32:25.557+00:00

Hello,

i´m trying to use System.Drawing in a linux web app, but i´m getting the exception below.

System.TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception.

System.DllNotFoundException: Unable to load shared library 'gdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgdiplus: cannot open shared object file: No such file or directory

I tried to execute the following commands in ssh shell, but still not working.

  • apt-get update
  • apt-get install -y --allow-unauthenticated libx11-dev
  • apt-get install -y --allow-unauthenticated libc6-dev
  • apt-get install -y --allow-unauthenticated libgdiplus

Running on Windows its working fine.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,244 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 24,076 Reputation points Microsoft Employee
    2020-04-09T20:51:47.537+00:00

    @Marcos Vinicius dos Santos , Apologies for the delay and any inconvenience with this! I completely understand this issue could be frustrating.

    If you haven't tried this already, kindly add the code in Stack setting >> as Startup command "apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev && dotnet yourwebappname.dll"

    You may checkout this document for more details on adding a startup script for Linux WebApp.

    7301-linuxstartupcmd.jpg

    If the issue still persist, to isolate, could you please check if this works locally in a Linux docker container and code issue (for cross platform version). Please check the approach outlined in this blog and see if it helps.
    Just as a side-note, this post contains a third-party site for your reference & convenience to you only.

    Kindly let us know if this helps or you need further assistance on this issue we will be more than happy to assist you.

    0 comments No comments