Message=GDI+ 中发生一般性错误。无法查明代码中发生错误的位置

Message=A generic error occurred in GDI+. Cannot pinpoint location in code where error occured

这个问题有很多变体,但我找不到我需要的答案。我唯一需要显示的是堆栈跟踪(类似于针对此问题发布的其他堆栈跟踪)从跟踪中,我无法确定代码中发生的位置。当时,代码应该一直在更新和添加到几个 listView 控件并进行一些文件写入。这个问题的答案有 运行 资源、文件锁、权限、字体、多线程和其他各种东西的范围,但我没有足够的信息来开始。如果有人能阐明这个堆栈告诉我的内容并提供可靠的 idea/answer 或者甚至是如何诊断或捕获问题的策略,我将不胜感激(我相信我的格式正确但如果我没有让它足够可读,我深表歉意)

System.Runtime.InteropServices.ExternalException was unhandled
  _HResult=-2147467259
  _message=A generic error occurred in GDI+.
  HResult=-2147467259
  IsTransient=false
  Message=A generic error occurred in GDI+.
  Source=System.Drawing
  ErrorCode=-2147467259
  StackTrace:
       at System.Drawing.Graphics.MeasureString(String text, Font font, SizeF layoutArea, StringFormat stringFormat)
       at System.Drawing.Graphics.MeasureString(String text, Font font, Int32 width)
       at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
       at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
       at System.Windows.Forms.Timer.TimerNativeWindow.OnThreadException(Exception e)
       at System.Windows.Forms.NativeWindow.Callback(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(IntPtr 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 Alpha_Strategy_Engine.Program.Main() in c:\Users\Jeffery\Documents\Visual Studio 2013\Projects\Alpha Strategy Engine\Program.cs:line 50
  InnerException: 

你的帖子好像被炸了, 您是否检查过 GDI 资源处理中的漏洞?

这是一个声称可以检测 GDI 泄漏的工具: http://www.codeproject.com/Tips/20264/GDI-Leak-Detector-A-special-debugger-to-detect-and

还有一个简单查看GDI句柄数量的工具(穷人的调试): http://www.nirsoft.net/utils/gdi_handles.html

还有一个关于它的 msdn 博客 post: http://blogs.msdn.com/b/dsui_team/archive/2013/04/23/debugging-a-gdi-resource-leak.aspx