簡體   English   中英

AWS Lambda Dot Net Core 3.1 在使用 Aspose Cells for.Net 時拋出 gdip 異常

[英]AWS Lambda Dot Net Core 3.1 throws gdip exception when using Aspose Cells for .Net

我正在使用 Aspose Cells for.Net 在 Dot Net Core 3.1 中將 Excel 轉換為 PDF。 它在本地環境中完美運行,但是當我在 AWS 環境(AWS Lambda)中托管時,它會拋出一個錯誤說,

{"fileName":"System.TypeInitializationException: 'Gdip' 的類型初始化程序拋出異常。---> System.DllNotFoundException: 無法加載共享庫 'libdl' 或其依賴項之一。為了幫助診斷加載問題,考慮設置 LD_DEBUG 環境變量: liblibdl: cannot open shared object file: No such file or directory\n at Interop.Libdl.dlopen(String fileName, Int32 flag)\n at System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary() \n 在 System.Drawing.SafeNativeMethods.Gdip..cctor()\n --- 內部異常堆棧跟蹤結束 ---\n 在 System.Drawing.SafeNativeMethods.Gdip.GdipNewPrivateFontCollection(IntPtr& fontCollection)\n 在 SelectPdf。 Lib.ᡜ..ctor()\n.

我在我的項目中引用了“System.Drawing.Common”DLL 來解決這個問題。 但是這個問題仍然沒有得到解決。 如何解決這個問題?

我們使用 Docker 容器嘗試了 Aspose.Cells 的場景,假設“AWS Lambdas”類似於 docker 容器。 我們已經在 docker 容器中的 Ubuntu 16.04 x64 上測試了這個問題。 以下是我們的步驟:

我們使用的docker是:microsoft/dotnet,先安裝:sudo docker pull microsoft/dotnet

然后,在直接運行后,我們在這個 docker 中遇到了問題,我們在保存到 PDF 時遇到了類似的錯誤。 我們做了以下事情來整理它:

我們安裝了 libgdiplus:

apt-get update
apt-get install -y libgdiplus
cd /usr/lib && ln -s libgdiplus.so gdiplus.dll

並安裝 libc6-dev:

apt-get install -y --no-install-recommends libc6-dev

我們發現PDF文件創建成功。

此外,請參閱有助於在 AWS lambda 環境中使用 Aspose.Cells 的線程供您參考。

PS。 我在 Aspose 擔任支持開發人員/傳播者。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM