Unable to load DLL 'libdl' when using System.Drawing.Common NuGet package on AWS Lambda

前端 未结 4 1802
死守一世寂寞
死守一世寂寞 2020-12-30 02:28

We have a thumbnail generator lambda function which I\'m trying to update to .NET Core 2.0, but I\'ve encountered the following error when using Microsoft\'s System.Dr

相关标签:
4条回答
  • 2020-12-30 03:05

    I had the same issue after uploading my application on Ubuntu 18 server running dotnet core 2.1.500 version. I resolved this issue with this solution https://github.com/dotnet/dotnet-docker/issues/618 using MichaelSimons suggestions.

    I ran

    #sudo apt-get update
    #sudo apt-get install -y --allow-unauthenticated \
            libc6-dev \
            libgdiplus \
            libx11-dev \ 
    #sudo rm -rf /var/lib/apt/lists/*
    

    This resolved the issues.

    0 讨论(0)
  • 2020-12-30 03:07

    I found a solution for this issue which worked for me:

    At first i removed the System.Drawing.Common library from the project, then i installed the library you can find here. It uses the same classes.

    using System.Drawing
    ...
    var bmp = new Bitmap(100,100);
    

    At last I installed this other library which contains all the dll's necesary for using drawing libraries on Linux and Lambda as well. By doing this steps the code can be uploaded to AWS without any problem.

    0 讨论(0)
  • 2020-12-30 03:12

    If one uses centOS, then below command helps.

    • sudo yum install libgdiplus
    0 讨论(0)
  • 2020-12-30 03:21

    For image processing in .NET Core Lambda I use the SixLabors.ImageSharp

    Here is the code I used in my recent AWS re:Invent talk that did a log if image processing:

    var imageBuffer = new MemoryStream();
    
    var resizeOptions = new ResizeOptions
    {
        Size = new SixLabors.Primitives.Size { Width = this.TileSize, Height = this.TileSize},
        Mode = ResizeMode.Stretch
    };
    image.Mutate(x => x.Resize(resizeOptions));
    image.Save(imageBuffer, new SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder());
    
    imageBuffer.Position = 0;
    
    0 讨论(0)
提交回复
热议问题