.net 通用GDI+;堆栈跟踪中的ThreadExceptionDialog出错

.net 通用GDI+;堆栈跟踪中的ThreadExceptionDialog出错,.net,winforms,exception,gdi+,.net,Winforms,Exception,Gdi+,我们收到了一些难以重现的错误报告。用户收到“发生错误。应用程序将立即退出”消息框,然后应用程序退出 在Main()中,我将异常写入日志文件: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.FromHbitmap(IntPtr hbitmap, IntPtr hpalette) at System.Drawing.Image.Fr

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

在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在堆栈跟踪中。我想这就是显示“发生错误。应用程序现在将退出”消息的对话框


这是一个无关的错误,还是对话框重新引发异常?如何获取原始异常?

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


您可以使用查看异常窗口来创建转储。

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


您可以使用查看异常窗口来创建转储。

看起来OnThreadException方法已被调用,这意味着您应该能够为事件设置事件处理程序,以便更详细地检查异常。

看起来OnThreadException方法已被调用,这意味着您应该能够为事件设置事件处理程序,以便更详细地检查异常。

如何让应用程序生成转储文件?它没有崩溃。一旦看到异常窗口,您可以在挂起模式下使用ADPlus创建转储。如何让应用程序生成转储文件?它没有崩溃。一旦看到异常窗口,您可以在挂起模式下使用ADPlus创建转储。