ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

.Net Core 使用 System.Drawing.Common 在CentOS下报错

2021-02-07 16:32:31  阅读:177  来源: 互联网

标签:Core imagetest1 CentOS libdl System 报错 usr Gdip Drawing


.Net Core MVC 项目,添加了图片上传处理功能,使用了 System.Drawing.Common 引用。

部署CentOS后,提示

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'libdl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory
   at Interop.Libdl.dlopen(String fileName, Int32 flag)
   at System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary()
   at System.Drawing.SafeNativeMethods.Gdip..cctor()
   --- End of inner exception stack trace ---
   at System.Drawing.SafeNativeMethods.Gdip.GdipLoadImageFromDelegate_linux(StreamGetHeaderDelegate getHeader, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, IntPtr& image)
   at System.Drawing.Image.InitFromStream(Stream stream)
   at System.Drawing.Image.LoadFromStream(Stream stream, Boolean keepAlive)
   at imagetest1.Program.Main(String[] args) in F:\imagetest1\imagetest1\Program.cs:line 13
C#

解决这个问题需要在CentOS中安装 libdl

#locate libdl
/usr/lib64/libdl-2.17.so
/usr/lib64/libdl.so.2
#cd /usr/lib64
#ln -s libdl-2.17.so libdl.so
 

然后又报另外一个错误:Unable to load DLL 'libgdiplus'

yum install libgdiplus-devel

转载:http://3624091.com/blogs/detail/21

标签:Core,imagetest1,CentOS,libdl,System,报错,usr,Gdip,Drawing
来源: https://www.cnblogs.com/yuany69/p/14385703.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有