如何解决winforms错误"GDI +中发生了一般性错误. &quot ;? [英] How to resolve the winforms error "A generic error occurred in GDI+. "?

查看:111
本文介绍了如何解决winforms错误"GDI +中发生了一般性错误. &quot ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#.net Win表单应用程序中遇到以下异常.

I am facing the following exception in my C#.net win forms application.

A generic error occurred in GDI+.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawRectangle(Pen pen, Int32 x, Int32 y, Int32 width, Int32 height)
at WeifenLuo.WinFormsUI.Docking.DockWindow.OnPaint(PaintEventArgs e)
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.ScrollableControl.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 

最令人困惑的一点是,当应用程序加载表单(包含一些丰富的图形)时,这种情况很少发生,WPF工作等),可以说成功加载表单的时间约为90%.但很少会复制它,而且仅在某些计算机上才可以复制,在其他一些计算机上,这种形式在100%的时间内都有效,并且永远不会遇到此异常.

我不知道为什么会发生这种异常,因为它也没有显示导致异常的确切堆栈跟踪.请提出一个关于如何处理它的想法.

The most confusing point is that, it occurs very rarely when the application loading a form (which contains some rich graphics, WPF work etc.), could say about 90% of the time the form is loaded successfully. but very few times it happens to be reproduced and also only on some machines, at some other machines this form is works 100% of the time and never face this exception.

I am not getting any idea why this exceptions happening, because it also not showing the exact stack trace which causes the exception. Please suggest if one have any idea about how to deal with it.

推荐答案

我最近也有同样的例外.实际上,我遇到的问题是程序试图将文件写入不存在的文件夹.该文件是从应用程序创建的gif.
现在您不会猜测,但是我创建了文件夹,一切正常.谁会认为通用GDI +异常确实与IO相关? :)
无论如何,经过一番谷歌搜索后,我发现更多的人遇到了这个问题.
解决"GDI +异常中发生一般错误 [搜索结果 [ ^ ]将有所帮助.
异常的问题在于它无法告诉您任何信息(我实际上认为这是代码缺陷,甚至是框架中的错误),因此您什么也不能告诉我们.因此,寻求帮助很困难.
无论如何,请检查代码是否需要(写入)对某些文件或文件夹的访问权,并确保文件或文件夹存在并且您具有写权限.
祝您有个含糊的例外!!
希望对您有所帮助:)
I recently had that same exception. Actually the problem I had was that a program was trying to write a file to a folder that didn''t exist. The file was a gif created from the application.
Now you wouldn''t guess, but I created the folder and everything went fine. Who would think a Generic GDI+ Exception would really be IO related? :)
Anyway, after Googling a bit I found more people have this problem.
Solving "A Generic Error Occurred In GDI+" Exception[^]
Perhaps one of these search results[^] will help.
The problem with this Exception is that it tells you nothing (I actually think this is a code flaw or even bug in the framework) and you can''t tell us anything as a result. So finding help is difficult.
Anyway, check if your code needs (write) access to some files or folders and make sure the file or folder exists and that you have permission to write.
Good luck with this vague Exception!
Hope it helps :)


这篇关于如何解决winforms错误"GDI +中发生了一般性错误. &quot ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆