SkiaSharp 图片生成库在docker中运行出错问题(未解决)

错误提示:

TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.

原因是docker中使用liunx的库,需要下载

解决方案:

Dockerfile 加入 RUN 命令,以官方 asp.net core runtime 镜像,以 asp.net core 2.2 作为示例:

FROM microsoft/dotnet:2.2.0-aspnetcore-runtime
WORKDIR /app
COPY . .
RUN apt-get update -y && apt-get install -y libgdiplus && apt-get clean && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
EXPOSE 80
ENTRYPOINT ["dotnet", "<你的入口程序集>"]

apt-get update 这一步是必不可少的,不然会报找不到 libgdiplus。

//也可在docker中运行下面命令
apt-get update -y 
apt-get install -y libgdiplus 
apt-get clean && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll

参考地址:

https://www.cnblogs.com/stulzq/p/10172550.html

https://www.cnblogs.com/OMango/p/8519980.html

原文地址:https://www.cnblogs.com/myfqm/p/13093153.html