【问题标题】:Generic GDI+ error with ThreadExceptionDialog in stack trace堆栈跟踪中带有 ThreadExceptionDialog 的通用 GDI+ 错误
【发布时间】:2009-04-30 12:21:01
【问题描述】:

我们收到了一些难以重现的错误报告。用户收到“发生错误。应用程序现在将退出”。消息框,然后应用退出。

在 Main() 中,我将异常写入日志文件:

System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.FromHbitmap(IntPtr hbitmap, IntPtr hpalette)
at System.Drawing.Image.FromHbitmap(IntPtr hbitmap)
at System.Drawing.Icon.ToBitmap()
at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
at System.Windows.Forms.Control.WndProcException(Exception e)
at System.Windows.Forms.Control.ControlNativeWindow.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(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 Wfm.AppMain.Main()

让我感到困惑的是 ThreadExceptionDialog 在堆栈跟踪中。我想那是显示“发生错误。应用程序现在将退出”的对话框。消息。

这是一个不相关的错误还是对话框重新抛出异常?如何获取原始异常?

【问题讨论】:

    标签: .net winforms exception gdi+


    【解决方案1】:

    似乎调用了 OnThreadException 方法,这意味着您应该能够为 Application.ThreadException 事件设置事件处理程序,以便更详细地检查异常。

    【讨论】:

      【解决方案2】:

      您需要一个转储文件,然后使用 SOS 获取堆栈上的所有异常对象。
      顺便说一句,那台机器上的资源情况如何?看起来应用程序无法将图标转换为位图,这可能会在极端资源压力下发生。

      您可以使用ADPlus in hang mode once 创建转储,您会看到异常窗口。

      【讨论】:

      • 如何让应用生成转储文件?它没有崩溃。
      • 看到异常窗口后,您可以在挂起模式下使用 ADPlus 创建转储。
      猜你喜欢
      • 2011-03-03
      • 2018-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-14
      • 1970-01-01
      • 2018-06-24
      • 2011-08-12
      相关资源
      最近更新 更多