1

这个问题有很多变体,但我找不到我需要的答案。我唯一需要显示的是堆栈跟踪(类似于为这个问题发布的其他堆栈跟踪) 从跟踪中,我无法确定代码中发生这种情况的位置。当时,代码应该已经更新并添加到几个 listView 控件并进行一些文件写入。这个问题的答案涵盖了资源、文件锁、权限、字体、多线程和其他各种东西,但我没有足够的信息来开始。如果有人能对这个堆栈告诉我的内容有所了解,并提供一个可靠的想法/答案,甚至是如何诊断或解决问题的策略,我将不胜感激(我相信我的格式正确,但很抱歉如果我没有

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: 
4

1 回答 1

0

看起来你的一个线程正在轰炸,你检查过你处理 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 博客文章:http: //blogs.msdn.com/b/dsui_team/archive/2013/04/23/debugging-a-gdi-resource-leak.aspx

于 2015-07-29T08:50:07.447 回答