.Net Core System.AWS Lambda出现绘图错误

时间:2018-10-11 14:47:38

标签: asp.net-core aws-lambda

我正在尝试使用.Net Core和AWS Lambda生成QRCode。但是,将System.Drawing库与lambda一起使用似乎存在问题。一切正常,直到我开始使用任何System.Drawing函数。 之前曾有人问过这个问题,但似乎没有任何好的解决方案。这是我当前在控制器中的代码:

    QRCodeGenerator qrGenerator = new QRCodeGenerator();
    QRCodeData qrCodeData = qrGenerator.CreateQrCode("hello", QRCodeGenerator.ECCLevel.Q);
    QRCode qrCode = new QRCode(qrCodeData); //works till here. Commented below does not work.
    //Bitmap qrCodeImageBitMap = qrCode.GetGraphic(20);
    List<string> testing = new List<string>();
    testing.Add("added");
    return Ok(testing);

这是CloudWatch日志中发现的错误的一部分:

[Error] Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction: Unknown error responding to request: TypeInitializationException:
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'libdl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory
at Interop.Libdl.dlopen(String fileName, Int32 flag)
at System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary()
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0...

如何使System.Drawing与lambda一起使用?我认为没有备用库,因为我需要绘图功能。我也在使用https://github.com/codebude/QRCoder中的QRCoder库,但这不会引起任何问题。

0 个答案:

没有答案