首页 新闻 会员 周边

.NET Core使用System.Drawing.Common时找不到libgdiplus的问题

0
悬赏园豆:30 [已解决问题] 解决于 2018-02-16 19:25

在 ASP.NET Core 中引用 System.Drawing.Common,在 Ubuntu 16.04 上运行时出现下面的错误:

System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libgdiplus': The specified module could not be found.
   at System.Runtime.InteropServices.FunctionWrapper`1.get_Delegate()
   at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
   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)
dudu的主页 dudu | 高人七级 | 园豆:30994
提问于:2018-02-16 18:05
< >
分享
最佳答案
2

操作系统中安装了gdi 库了吗?祥见CoreCompat的github仓库

收获园豆:30
蝌蝌 | 初学一级 |园豆:158 | 2018-02-16 18:30
dudu | 园豆:30994 (高人七级) | 2018-02-16 19:25

@dudu: 用了这两个方法我展示的验证码出来是乱码。。。。是啥原因呀?

一直在飞 | 园豆:204 (菜鸟二级) | 2018-06-08 15:16

@一直在飞: 建议博问中专门提问一下

dudu | 园豆:30994 (高人七级) | 2018-06-08 16:34

后来在 docker 容器中使用 System.Drawing.Common 遇到了新的问题,详见 asp.net core 2.1 容器中使用 System.Drawing.Common 的问题

dudu | 园豆:30994 (高人七级) | 2018-08-22 16:29
其他回答(4)
0

用了这两个方法我展示的验证码出来是乱码。。。。是啥原因呀?

一直在飞 | 园豆:204 (菜鸟二级) | 2018-06-08 15:16
0

乱码传送门  http://www.cnblogs.com/xxff/p/9363477.html#4027986

晓风.NET | 园豆:204 (菜鸟二级) | 2018-07-25 00:36
0

不错,解决了

runningprogrammer | 园豆:214 (菜鸟二级) | 2018-09-25 21:40
0

可以帮我看下是什么问题吗,我的服务器是centos7,我已经安装了libgdiplus,但是执行cd /usr/lib && ln -s libgdiplus.so gdiplus.dll命令的时候提示我gdiplus.dll文件不存在,但是我find了一下,确实有这个文件......
我的.net core部署到centos7上以后,有个文件保存的操作,将base64转成图片,下面是我的代码:

本地是可以保存图片的,就线上不行,所以问题应该还是处在服务器环境上, 不知道是哪里不对。

顾星河 | 园豆:7173 (大侠五级) | 2018-11-14 11:36

ln -s libgdiplus.so gdiplus.dll 是把 gdiplus.dll 软链接到 libgdiplus.so ,是针对没 gdiplus.dll 文件的情况,而你的 centos 中是有 gdiplus.dll 的,情况不一样

支持(0) 反对(0) dudu | 园豆:30994 (高人七级) | 2018-11-14 12:59

@dudu: 原来是这样,对了,我刚重启了一下服务器,再运行程序,可以把图片上传过去了(/ω\)
估计是没重启就没生效,不过我的图片路径存得不对,我想在应用程序根目录创建Images文件夹,然后再存下面,现在直接存在根目录下了

支持(0) 反对(0) 顾星河 | 园豆:7173 (大侠五级) | 2018-11-14 13:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册