首页 文章

使用Select.HtmlToPdf.NetCore时,Dockerized Dotnet Core 2.1会引发Gdip异常

提问于
浏览
2

我正在使用Select.HtmlToPdf.NetCore(18.3.0)将Html转换为Dotnetcore 2.1中的pdf . 它在本地环境中完美地工作,但是当使用Docker托管它会抛出一个错误说,

{“fileName”:“System.TypeInitializationException:'Gdip'的类型初始值设定项引发异常.---> System.DllNotFoundException:无法加载共享库'libdl'或其依赖项之一 . 为了帮助诊断加载问题,考虑设置LD_DEBUG环境变量:liblibdl:无法打开共享对象文件:没有这样的文件或目录\ n在Interop.Libdl.dlopen(String fileName,Int32 flag)\ n在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在SelectPdf.Lib . ៞..ctor()\ n在SelectPdf.Lib . ៞..ctor(ᡏA_0,᠝A_1)\ n在SelectPdf.HtmlToPdf . ᜁ(String A_0,String A_1,String A_2,String A_3,Boolean A_4)\ n在SelectPdf.HtmlToPdf.ConvertHtmlString(String htmlString)

我试过在Dockerfile中添加这些行,但仍然有相同的错误 .

FROM microsoft / dotnet:2.1-aspnetcore-runtime AS base
运行apt-get update
运行apt-get install -y apt-utils
运行apt-get install -y libgdiplus
运行ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
WORKDIR / app
EXPOSE 80

1 回答

  • 0

    您需要在Docker容器中安装 libc6-dev . 您可以通过运行以下命令来安装libc6-dev:

    RUN apt-get install -y libc6-dev
    

    让我知道这是怎么回事 .

相关问题