Dockerized Dotnet Core 2.1 throws Gdip exception when using Select.HtmlToPdf.NetCore

Dockerized Dotnet Core 2.1 throws Gdip exception when using Select.HtmlToPdf.NetCore



I am using Select.HtmlToPdf.NetCore(18.3.0) to convert Html to pdf in Dotnetcore 2.1. It is perfectly working in local environment but when hosted with Docker it throws an error saying,



{"fileName":"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 directoryn at Interop.Libdl.dlopen(String fileName,
Int32 flag)n at
System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary()n at
System.Drawing.SafeNativeMethods.Gdip..cctor()n --- End of inner
exception stack trace ---n at
System.Drawing.SafeNativeMethods.Gdip.GdipNewPrivateFontCollection(IntPtr&
fontCollection)n at SelectPdf.Lib.ᡜ..ctor()n at
SelectPdf.Lib.៞..ctor()n at SelectPdf.Lib.៞..ctor(ᡏ A_0, ᠝ A_1)n

at SelectPdf.HtmlToPdf.ᜁ(String A_0, String A_1, String A_2, String
A_3, Boolean A_4)n at SelectPdf.HtmlToPdf.ConvertHtmlString(String
htmlString)



I have tried by adding these set of lines in Dockerfile, but still having the same error.



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





Are you trying to host on Windows or Linux based engine?
– Mohsin Mehmood
Aug 29 at 5:43





I have tried with both.worked none for me.
– Isuru Amarathunga
Aug 29 at 7:28





Check this open issue on github: github.com/dotnet/corefx/issues/25102
– Mohsin Mehmood
Aug 29 at 8:04





Thanks Mohsin. I've already followed up those steps but it didn't help. I've raised this to owners of Select.HtmlToPdf.NetCore.
– Isuru Amarathunga
Aug 30 at 6:03





1 Answer
1



You need to install libc6-dev in your Docker container. You can install libc6-dev by running the following command:


libc6-dev


RUN apt-get install -y libc6-dev



Let me know how that goes.





In my question I have mentioned the above command did not work for me. Thanks for your answer.
– Isuru Amarathunga
Sep 19 at 3:43






Apologies, you need to install libc6-dev. Can you try that? I've updated the answer.
– Frederik Carlier
Sep 19 at 14:04






I am sorry. Still having the same error. Thanks for the help.
– Isuru Amarathunga
Sep 23 at 10:11







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế