cecilzhw 2019-02-11 20:52 采纳率: 100%
浏览 2582
已采纳

WPF程序运行在windows10 x64电脑上,偶尔在点击时奔溃闪退

点击程序很简单,显示一个对话框:
BatchTest batch = new BatchTest();
batch.ClearMainChannelData += ClearChannelData;
batch.ShowDialog();

程序闪退,无法看到更多信息,在windows事件查看器中看到以下信息:

描述:
应用程序: SuperFlex.exe
Framework 版本: v4.0.30319
说明: 由于未经处理的异常,进程终止。
异常信息: 异常代码为 c0000005,异常地址为 765C8846
堆栈:
在 MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
在 MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr, Int32, IntPtr, IntPtr)
在 MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
在 MS.Win32.UnsafeNativeMethods.ShowWindow(System.Runtime.InteropServices.HandleRef, Int32)
在 System.Windows.Window.ShowHelper(System.Object)
在 System.Windows.Window.Show()
在 System.Windows.Window.ShowDialog()
在 SuperFlex.MainView.ToolButton_OnClick(System.Object, System.Windows.RoutedEventArgs)
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
在 System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
在 System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs)
在 System.Windows.Controls.Primitives.ButtonBase.OnClick()
在 System.Windows.Controls.Primitives.ToggleButton.OnClick()
在 System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs)
在 System.Windows.UIElement.OnMouseLeftButtonUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)
在 System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object)
在 System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
在 System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject, System.Windows.RoutedEventArgs, System.Windows.RoutedEvent)
在 System.Windows.UIElement.OnMouseUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)
在 System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object)
在 System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
在 System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
在 System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
在 System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean)
在 System.Windows.Input.InputManager.ProcessStagingArea()
在 System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
在 System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport)
在 System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawMouseActions, Int32, Int32, Int32)
在 System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr, MS.Internal.Interop.WindowMessage, IntPtr, IntPtr, Boolean ByRef)
在 System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
在 MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
在 MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
在 System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
在 System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
在 System.Windows.Application.RunDispatcher(System.Object)
在 System.Windows.Application.RunInternal(System.Windows.Window)
在 System.Windows.Application.Run(System.Windows.Window)
在 System.Windows.Application.Run()
在 SuperFlex.App.Main()

  • 写回答

2条回答 默认 最新

  • hxycsdn9159 2019-02-12 17:33
    关注

    异常说明很清楚了:在调用showdialog方法时无法处理窗口消息造成对话框无法显示抛出的异常,造成这个的原因有很多,看你这个抛出来的异常信息是正在处理布局的时候发生的,有可能是wpf正在忙于计算布局的短暂间隔执行了showdialog方法造成无法及时去处理这个窗口消息,所以有时候计算的快就不会报错,有时候计算的慢导致无法及时处理这个消息就挂了,你可以尝试去人为去干涉一下窗口弹出的时机,尝试一下用这个方法能不能解决:Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>batch.ShowDialog()))

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格