我是靠谱客的博主 激昂抽屉,这篇文章主要介绍NETCore 项目部署报错: “The type initializer for ‘Gdip‘ threw an exception”概述,现在分享给大家,希望可以做个参考。
文章目录
- 概述
- 方案一
- 方案二
概述
asp .net core 项目 部署在docker中,文件导出使用了System.Drawing.Common包,在容器中使用时报错“The type initializer for ‘Gdip’ threw an exception.” 排查了一下,发现是docker容器中 System.Drawing.Common Gdiplus 相关依赖缺失的缘故
方案一
1.远程连接服务器
2.输入指令
1、apt-get install libgdiplus
2、cd /usr/lib
3、ln -s libgdiplus.so gdiplus.dll 或 sudo ln -s libgdiplus.so gdiplus.dll
3.修改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
方案二
在方案一基础上:项目文件中安装ereno.linux-x64.eugeneereno.System.Drawing 并引用:
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Drawing.EnableUnixSupport" Value="true" />
</ItemGroup>
至此问题解决。
最后
以上就是激昂抽屉最近收集整理的关于NETCore 项目部署报错: “The type initializer for ‘Gdip‘ threw an exception”概述的全部内容,更多相关NETCore内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复