Image.FromFile()或FromStream()挂起在GdiplusStartup上

Bor*_*ris 5 .net c# mono xamarin

我有一个包含这一行的简单C#应用程序:

var mImage = System.Drawing.Image.FromFile(filename);
Run Code Online (Sandbox Code Playgroud)

在Windows(.NET)上运行此代码时,正确加载图像.在OS X(Mono)上运行相同的代码时,应用程序就会挂起.调试器永远保持在该调用中.没有例外也没有.

callstack显示应用程序挂起:

System.Drawing.GDIPlus.GdiplusStartup()

这可能会出错?

PS:我安装了最新版本的Xamarin Studio和Mono.

Jer*_*son 5

1)不仅检查你有最新的Xamarin Studio版本,还检查你有最新的版本!

错误报告:

Troy Dawson 在一个多月前使用Xamarin Studio版本5.5(build 198)报告了这个问题:https://bugzilla.xamarin.com/show_bug.cgi?id = 23444

"使用alpha发布通道中的最新Mono,附加项目应该在运行时引发一个类型未发现的异常:

var image = Image.FromStream(content);
Run Code Online (Sandbox Code Playgroud)

因为GDIPlus无法初始化或什么的.

这类似于我提交的另一个错误,其中Image.FromStream()在首次运行Mono时需要很长时间才能返回.

完全例外:

System.Drawing.GDIPlus ---> System.Exception的类型初始化程序抛出异常:GdiplusStartup

解:

在2014-09-29报告错误后的第二天,Sadik Ali确认他可以重现问题评论1,然后4天后,Troy Dawson确认Xamarin Studio版本5.5(版本227)修复了问题 评论2.


2)如果它仍然以最新版本失败,我建议你通过限制并确保支持你加载的图像:https: //github.com/mono/libgdiplus/blob/master/TODO