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

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条)

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式