asp .net core 部署在docker中,报错 The type initializer for 'Gdip' threw an exception.
asp .net core 部署在docker中,使用了System.Drawing.Common包,在容器中使用时报错“The type initializer for 'Gdip' threw an exception.”
原因:在docker容器中缺少gdip的依赖文件
方案:
1.安装
2.在/usr/lib文件下可以找到
3.sudo ln -s libgdiplus.so gdiplus.dll
4.要是到这一步你还是失败的,那就继续搞一下环境变量(我到这一步就好了)
LD_LIBRARY_PATH=/usr/lib
dockerfile的修改:
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
RUN ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
就Ok啦