2014-02-28 28 views
0

我正在做一個vb.net應用程序,其中用戶需要登錄到系統。如果系統崩潰或停止,我將如何更改其登錄狀態以註銷?我會做什麼來自動註銷系統中的用戶?謝謝提前。你的回答對我來說是很大的幫助。自動註銷用戶,當vb.net 2008應用程序關閉或崩潰

+0

http://stackoverflow.com/questions/10519161/catching-application-crash-events – qwr

回答

0

除非您在遇到錯誤時發現錯誤並執行某些操作或重新編寫代碼執行方向,否則無法執行此操作。你可以這樣做...

Try 
'Whatever regular code 
Catch ex as Exception 
'Upon encountering error do the logout code here 
Finally 
'This part executes whether your app encounters error or not, so if you just want to logout when your app meets the error, you can leave this blank. 
End Try 

如果錯誤是連接到數據庫的錯誤,這將不起作用。

+0

感謝您的迴應,我會應用您的建議,但我會在哪裏將代碼放在主窗體中?謝謝 – user3363439

+0

您需要將代碼放入任何SUB,事件,功能中,尤其是最容易出現意外錯誤的功能,例如將數據插入數據庫等,或者以C語言如何調用它們的揮發性值。如果它確實回答你的問題,請將我的帖子標記爲已回答:)謝謝。 –