【发布时间】:2019-02-03 19:11:37
【问题描述】:
我在 Dotnetcore 2.1 中使用 Select.HtmlToPdf.NetCore(18.3.0) 将 Html 转换为 pdf。它在本地环境中完美运行,但使用 Docker 托管时会抛出错误提示,
{"fileName":"System.TypeInitializationException: 类型初始化器 对于 'Gdip' 抛出异常。 ---> System.DllNotFoundException: 无法加载共享库“libdl”或其依赖项之一。在 为了帮助诊断加载问题,请考虑设置 LD_DEBUG 环境变量:liblibdl:无法打开共享对象文件:否 此类文件或目录\n 在 Interop.Libdl.dlopen(String fileName, Int32 标志)\n 在 System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary()\n at System.Drawing.SafeNativeMethods.Gdip..cctor()\n --- 内部结束 异常堆栈跟踪 ---\n at System.Drawing.SafeNativeMethods.Gdip.GdipNewPrivateFontCollection(IntPtr& fontCollection)\n 在 SelectPdf.Lib.ᡜ..ctor()\n 在 SelectPdf.Lib...ctor()\n 在 SelectPdf.Lib...ctor(ᡏ A_0, A_1)\n
在 SelectPdf.HtmlToPdf.ᜁ(字符串 A_0,字符串 A_1,字符串 A_2,字符串 A_3,布尔 A_4)\n 在 SelectPdf.HtmlToPdf.ConvertHtmlString(String htmlString)
我尝试在 Dockerfile 中添加这些行,但仍然出现相同的错误。
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y libgdiplus
RUN ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
WORKDIR /app
EXPOSE 80
【问题讨论】:
-
您是否尝试在基于 Windows 或 Linux 的引擎上进行托管?
-
我都试过了。对我没有用。
-
在 github 上查看这个未解决的问题:github.com/dotnet/corefx/issues/25102
-
谢谢莫辛。我已经按照这些步骤进行了操作,但没有帮助。我已经向 Select.HtmlToPdf.NetCore 的所有者提出了这个问题。