|
-
Aug 24th, 2007, 10:26 AM
#1
Thread Starter
Lively Member
[2005] Write to file on terminate
If my program crashes, is there a way to write data to a file before it actually terminates?
-
Aug 24th, 2007, 10:31 AM
#2
Re: [2005] Write to file on terminate
i don't think so...
crash means unexpected end of the program, so i think there isn't no way to handle that...
-
Aug 24th, 2007, 08:04 PM
#3
Re: [2005] Write to file on terminate
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.
-
Aug 24th, 2007, 08:08 PM
#4
Thread Starter
Lively Member
Re: [2005] Write to file on terminate
 Originally Posted by jmcilhinney
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.
oops ... i dont think i use a main method
-
Aug 24th, 2007, 08:32 PM
#5
Re: [2005] Write to file on terminate
 Originally Posted by jeffnyc
oops ... i dont think i use a main method
And thats perfectly normal, if its a normal WinForms app, as jmcilhinney stated.
-
Aug 25th, 2007, 12:10 AM
#6
Thread Starter
Lively Member
Re: [2005] Write to file on terminate
 Originally Posted by Atheist
And thats perfectly normal, if its a normal WinForms app, as jmcilhinney stated.
so given that.. what should i do?
-
Aug 25th, 2007, 01:33 AM
#7
Re: [2005] Write to file on terminate
 Originally Posted by jeffnyc
so given that.. what should i do?
This:
 Originally Posted by jmcilhinney
Assuming that you're building a Windows Forms application, then you handle the UnhandledException event of the application.
-
Aug 25th, 2007, 04:32 AM
#8
Re: [2005] Write to file on terminate
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|