0
Q
作出錯誤窗口
A
回答
1
所以你要調用自定義的處理程序時發生異常?沒問題,只要定義你的程序的開頭這3個魔紋(爲Sub Main
第一行):
AddHandler Application.ThreadException, AddressOf GenericHandler
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException)
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledHandler
然後定義GenericHandler和UnhandledHandler,它會叫你的自定義窗體。
這裏既是處理程序的實現:
Public Shared Sub GenericHandler(ByVal sender As Object, ByVal args As Threading.ThreadExceptionEventArgs)
ReportException(args.Exception)
End Sub
Public Shared Sub UnhandledHandler(ByVal sender As Object, ByVal args As UnhandledExceptionEventArgs)
If Not Debugger.IsAttached Then
ReportException(args.ExceptionObject)
End
End If
Public Shared Sub ReportException(ByVal ex As System.Exception)
MsgBox(ex.ToString, MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "Unhandled exception - Please contact support")
'you can further improve this to add custom logging etc.
End Sub
相關問題
- 1. 彈出窗口(不是錯誤彈出窗口)
- 2. 彈出窗口出現css錯誤
- 3. 關閉窗口時KendoUI窗口彈出錯誤
- 4. 退出錯誤Internet Explorer窗口
- 5. 彈出窗口和UIAlertController錯誤
- 6. C#DriveInfo類使窗口錯誤彈出
- 7. Python,tkinter彈出窗口錯誤
- 8. 彈出窗口雖然沒有錯誤
- 9. Pyscripter:禁用彈出窗口的錯誤
- 10. 窗口。的ShowDialog()拋出錯誤
- 11. jquery.ValidationEngine - 刪除錯誤彈出窗口
- 12. 單擊2彈出窗口錯誤
- 13. python硒錯誤日誌彈出窗口
- 14. SFML - 窗口錯誤
- 15. 窗口closeAction錯誤
- 16. OpenGL窗口錯誤
- 17. Tensorflow窗口錯誤
- 18. 製作合成關閉錯誤窗口
- 19. 輸出和編譯器錯誤窗口在CS6中不工作
- 20. Qt嘗試顯示窗口時出現錯誤分段錯誤
- 21. Java窗口座標錯誤
- 22. 窗口錯誤處理
- 23. 窗口打開錯誤?
- 24. 錯誤archive_command窗口7
- 25. 模態窗口錯誤
- 26. 信息窗口錯誤
- 27. Powerbuilder數據窗口錯誤
- 28. Lua和c + +錯誤窗口
- 29. 窗口類型錯誤
- 30. 網址錯誤/ MAMP窗口
+1這一切,而我一直在周圍到處都是我的嘗試捕捉代碼! – AbZy
坦克你非常, –
@KazemFallahi:如果我的回答很有幫助,請考慮接受和/或upvoting它。 – Neolisk