"GDI +中发生一般错误".用动画GIF加载PictureBox之后 [英] "A generic error occurred in GDI+" after loading a PictureBox with an animated GIF
本文介绍了"GDI +中发生一般错误".用动画GIF加载PictureBox之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在.NET 2.0中有一个Windows Forms应用程序,在窗体上有一个PictureBox,并通过设置PictureBox的ImageLocation属性将其与动画GIF一起加载.当该动画渲染下一帧时,我得到以下异常和堆栈跟踪:
I have a Windows Forms application in .NET 2.0 with a PictureBox on a form and I load it with an animated GIF by setting the PictureBox's ImageLocation property. When it is time for the animation to render the next frame, I get the following exception and stack trace:
A generic error occurred in GDI+.
at System.Drawing.Image.SelectActiveFrame(FrameDimension dimension, Int32 frameIndex)
at System.Drawing.ImageAnimator.ImageInfo.UpdateFrame()
at System.Drawing.ImageAnimator.UpdateFrames()
at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at AIRNow.IMS.Mapper.MapWizard.Main() in C:\Projects\AIRNowI\IMS\UserInterface\MapWizard\MapWizard.cs:line 14
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
推荐答案
我不确定为什么会发生这种情况,但是我找到了解决方法.我将PictureBox的WaitOnLoad属性设置为True.如果我将其更改为False(默认值),则可以解决此问题.
I'm not entirely sure why this happens, but I found a workaround. I had the PictureBox's WaitOnLoad property set to True. If I change it to False (the default) it resolves the issue.
这篇关于"GDI +中发生一般错误".用动画GIF加载PictureBox之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文