If my program crashes, is there a way to write data to a file before it actually terminates?
Printable View
If my program crashes, is there a way to write data to a file before it actually terminates?
i don't think so...
crash means unexpected end of the program, so i think there isn't no way to handle that...
You should handle all the exceptions you can possibly think of that could reasonably be thrown by your code. Assuming that you're building a Windows Forms application, then you handle the UnhandledException event of the application. Note that this will not have any effect while debugging, only in a Release build.
If it's not a WinForms app then you can just put the entire contents of the Main method inside a Try...Catch block.
Quote:
Originally Posted by jmcilhinney
oops ... i dont think i use a main method
And thats perfectly normal, if its a normal WinForms app, as jmcilhinney stated.Quote:
Originally Posted by jeffnyc
Quote:
Originally Posted by Atheist
so given that.. what should i do?
This:Quote:
Originally Posted by jeffnyc
Quote:
Originally Posted by jmcilhinney
Go to the Application tab of the project properties, press the View Application Events button, use the drop-down lists at the top of the code window to create a handler for the UnhandledException event and then place whatever code you want executed when your app encounters an unexpected fatal error in that method.