【发布时间】:2013-05-08 07:40:45
【问题描述】:
我在 UltraToolbarsManager (Infragistics) 的功能区中的某处遇到未处理的异常。但这不是我想在这里问的相关部分。我的问题是:为什么我在堆栈跟踪中看不到我的应用程序的任何方法?堆栈跟踪仅显示 Infragistics 和 Windows 窗体模块。
复制场景非常罕见,但很少出现这种情况,总是在机器将要挂起模式时。异常由 Application.ThreadException 事件处理程序处理,我没有机会从其他位置捕获(表单已加载并使用 Applicatioin.Run() 运行)。
以下是异常详情:
The handle is invalid
System.ComponentModel.Win32Exception
Stack Trace:
bei System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
bei System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize)
bei System.Drawing.Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
bei Infragistics.Win.ControlUIElementBase.CaptureOldImage(UIElement element)
bei Infragistics.Win.TransitionInfo..ctor(UIElement element, Transition transition, TransitionSettings settings)
bei Infragistics.Win.ControlUIElementBase.InitiateTransition(TransitionSettings settings, Transition transition, UIElement element)
bei Infragistics.Win.UIElement.InitiateTransition(TransitionSettings settings, UIElementTransitionType transitionType)
bei Infragistics.Win.UltraWinToolbars.RibbonGroupUIElement.OnMouseLeave()
bei Infragistics.Win.ControlUIElementBase.ElementEntered(UIElement element, Boolean triggerMouseLeavesOnly)
bei Infragistics.Win.ControlUIElementBase.SyncMouseEntered(Boolean triggerMouseLeavesOnly, UIElementInputType inputType, Boolean ignoreLastElementEntered)
bei Infragistics.Win.ControlUIElementBase.ProcessMouseLeave(Object sender, EventArgs e)
bei Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e)
bei Infragistics.Win.UltraControlBase.OnMouseLeave(EventArgs e)
bei Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea.OnMouseLeave(EventArgs e)
bei System.Windows.Forms.Control.WmMouseLeave(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
除了从 Application.ThreadException 事件之外,有没有其他方法可以捕获异常,我可以在其中看到更多详细信息?
该异常是在创建表单时在同一个线程上处理的,所以我认为它不是由另一个线程修改 UI 引起的。
如果有任何帮助或提示,我将不胜感激。
最好的问候,
迈克尔
【问题讨论】:
-
很难说。似乎在鼠标退出功能区组(MouseLeave 事件)时触发。格式错误的工具提示文本或什么?这只是一个猜测。
-
确实,这也是我的第一个想法,我尝试复制它。但在另一种情况下,初始方法不是 MouseLeave 而是 Paint 事件。
-
当你泄漏窗口句柄时会发生这种异常。当您的程序消耗了其中的 10,000 个并且 Windows 不再愿意让您创建另一个时,就会发生 kaboom。 Winforms 编程中的一个非常常见的错误,使用 Controls.Clear() 或 Controls.Remove/At() 而不释放控件是导致永久泄漏的好方法。您可以使用任务管理器进行诊断,查看 + 选择列,勾选 USER32 对象。