在linux 或docker中使用 system.drawing.common

在dockerfile 中添加

FROM microsoft/dotnet:2.1-aspnetcore-runtime
RUN apt-get update RUN apt-get install -y --no-install-recommends libgdiplus libc6-dev

为什么会找不到 libdl (libdl.so.2) 呢?是因为 System.Drawing.Common 是在 /usr/lib/x86_64-linux-gnu/ 这个路径中找的,而容器中 libdl.so.2 存在于 /lib/x86_64-linux-gnu/ 目录中,安装 libc6-dev 之后 /lib/x86_64-linux-gnu/ 中就有了 libdl.so.2 ,问题就解决了。

现在不需要 ln -s libgdiplus.so gdiplus.dll ,System.Drawing.Common 已经改了代码,直接加载 libgdiplus.so ,详见实现源码

解决方法是在 https://github.com/VahidN/EPPlus.Core/issues/40 的回复中发现的

原文地址:https://www.cnblogs.com/leon-ytparty/p/10811419.html