Docker下配置.NET Core NPOI 环境 电脑版发表于:2021/9/14 17:19  >#Docker下配置.NET Core NPOI 环境 [TOC] 问题原因 ------------ tn2>在通过NPOI在linux环境下进行打包时会出现环境问题。 ```bash [[NPOI ERROR]]:The type initializer for 'Gdip' threw an exception. ``` 解决方法 ------------ tn>在Linux上,您需要安装 libgdiplus。从1.2.0开始,还需要libdl。 tn2>Ubuntu 16.04及以上版本配置 ```bash apt-get install libgdiplus libc6-dev cd /usr/lib ln -s libgdiplus.so gdiplus.dll ``` tn2>Fedora 23及以上版本配置 ```bash dnf install libgdiplus cd /usr/lib64/ ln -s libgdiplus.so.0 gdiplus.dll ``` tn2>CentOS 7及以上版本配置 ```bash yum install autoconf automake libtool yum install freetype-devel fontconfig libXft-devel yum install libjpeg-turbo-devel libpng-devel giflib-devel libtiff-devel libexif-devel yum install glib2-devel cairo-devel git clone https://github.com/mono/libgdiplus cd libgdiplus ./autogen.sh make make install cd /usr/lib64/ ln -s /usr/local/lib/libgdiplus.so gdiplus.dll ``` tn2>Docker中配置 >### Alpine ```bash RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories RUN apk --update add libgdiplus ``` >### Debian ```bash FROM microsoft/dotnet:2.1-aspnetcore-runtime RUN apt-get update && apt-get install -y libgdiplus libc6-dev && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll ``` 更多 ------------ tn2>参考:https://www.cjavapy.com/article/677/