Runtime: System.Drawing.Common not work on Amazon Linux AMI

Created on 19 Mar 2020  路  3Comments  路  Source: dotnet/runtime

Hi, my project was using System.Drawing.Common to get image size
It's work OK on window, but when I deploy on AWS it throw exception " One or more errors occurred. (The type initializer for 'Gdip' threw an exception.)"
I was research and know I need install "libgdiplus"
But aws can't install libgdiplus

what should I do now ?

area-System.Drawing untriaged

Most helpful comment

For anyone else who comes across this problem and doesn't have the luxury of using an alternative library libgdiplus can be installed through EPEL on Amazon Linux with:

sudo amazon-linux-extras install epel
sudo yum install libgdiplus

I've confirmed this works with Elastic Beanstalk

All 3 comments

There is no way how this could work without libgdi. That is OS dependency .NET needs.
cc: @safern

Hello @godshades... as @wfurt mentioned this can't work without having libgdiplus installed. However, we can resolve libgdiplus in other ways, you can deploy it as part of your app (if that doesn't work, set LD_LIBRARY_PATH env variable to point to the path where libgdiplus is).

Also, if that doesn't meet your expectations or it is too much for what you need, I recommend looking at: https://github.com/SixLabors/ImageSharp it is a completely managed implementation for image manipulation. Our Unix story for System.Drawing was mostly done for compat so the story is not ideal sometimes, however we're looking how to improve in future releases.

I'm going to close this issue, feel free to reopen or keep the discussion going.

For anyone else who comes across this problem and doesn't have the luxury of using an alternative library libgdiplus can be installed through EPEL on Amazon Linux with:

sudo amazon-linux-extras install epel
sudo yum install libgdiplus

I've confirmed this works with Elastic Beanstalk

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bencz picture bencz  路  3Comments

noahfalk picture noahfalk  路  3Comments

omajid picture omajid  路  3Comments

btecu picture btecu  路  3Comments

chunseoklee picture chunseoklee  路  3Comments