WPF程式運行一段時間崩潰,有全域例外捕獲,但是捕獲不到。
在windows事件管理器找到如下記錄,求大佬分析一下
應用程式: PCDemo.exe
Framework 版本: v4.0.30319
說明: 由于未經處理的例外,行程終止。
例外資訊: 例外代碼為 c0000005,例外地址為 6A428C61
堆疊:
在 System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(System.Runtime.InteropServices.HandleRef)
在 System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(System.Runtime.InteropServices.HandleRef)
在 System.Windows.Forms.NativeWindow.DestroyHandle()
在 System.Windows.Forms.Control.DestroyHandle()
在 System.Windows.Forms.Control.Dispose(Boolean)
在 System.Windows.Forms.Integration.WinFormsAdapter.Dispose(Boolean)
在 System.ComponentModel.Component.Dispose()
在 System.Windows.Forms.Integration.WindowsFormsHost.DestroyWindowCore(System.Runtime.InteropServices.HandleRef)
在 System.Windows.Interop.HwndHost.DestroyWindow()
在 System.Windows.Interop.HwndHost.Dispose(Boolean)
在 System.Windows.Forms.Integration.WindowsFormsHost.Dispose(Boolean)
在 System.Windows.Interop.HwndHost+WeakEventDispatcherShutdown.OnShutdownFinished(System.Object, System.EventArgs)
在 System.EventHandler.Invoke(System.Object, System.EventArgs)
在 System.Windows.Threading.Dispatcher.ShutdownImplInSecurityContext(System.Object)
在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
在 MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
在 System.Windows.Threading.Dispatcher.ShutdownImpl()
在 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)
在PCDemo.App.Main()
uj5u.com熱心網友回復:
還有一個錯誤應用程式名稱: PCDemo.exe,版本: 1.0.0.0,時間戳: 0xf11baba3
錯誤模塊名稱: PM101DA.dll,版本: 4.1.404.6,時間戳: 0x5f372c65
例外代碼: 0xc0000005
錯誤偏移量: 0x00008c61
錯誤行程 ID: 0xe508
錯誤應用程式啟動時間: 0x01d6ea837df46e54
錯誤應用程式路徑: C:\Release\PCDemo
錯誤模塊路徑: C:\Release\Dll\PM101DA.dll
報告 ID: a230aef2-e56c-496d-b6ea-6d3146551283
錯誤程式包全名:
uj5u.com熱心網友回復:
程式里使用了Winform的PictureBox的句柄,PM101DA.dll通過句柄在Picturebox上顯示畫面uj5u.com熱心網友回復:
Form 退出未做 非托管清理,導致PM101DA.dll在后臺重繪訪問時,訪問了已釋放的句柄uj5u.com熱心網友回復:
這個例外捕獲不到嗎?,我有做全域的例外捕獲。在包含PictureBox的Usercontrol Unloaded時做了清理作業。難道時PM101DA.dll內部的問題?uj5u.com熱心網友回復:
此例外為SEH例外(也就是未映射例外),默認不能捕獲。除非你自己顯示捕獲,有關此處問題清自己百度“C# SEHException”
uj5u.com熱心網友回復:
好的,感謝大佬,我去查一下資料uj5u.com熱心網友回復:
ps:建議在 Dispose里去做釋放動作,比如停止錄制,停止渲染等動作。也可以把handle提升成class的成員,這樣class Dispose前至少不會發生例外
uj5u.com熱心網友回復:
1 是如何捕獲全域變數的?2 是否使用了非托管功能?
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/251009.html
標籤:C#
下一篇:為了學英語,我做了個英漢字典.
