user3494322
user3494322

Reputation: 311

vb.net Run on crash

My program runs for about 10 hours during the night, sometimes I wake up to see that it has crashed (for whatever reason). It is usually a "Program Name" has stopped working, and the only button there is to close the program. I have tried watching and waiting for it to crash but the problem seems very hard to reproduce (and I can't watch it 24/7). I have used try and catch statements in my program in potentially problematic areas and told the program to dump to a text file if it catches an exception. But this isn't good enough it seems.

TLDR: Is it possible to tell my program to run a particular function when an exception has been detected in the program in general (without specifics) so that I can dump the stacktrace to a text file and investigate later?

Upvotes: 1

Views: 288

Answers (2)

Heinzi
Heinzi

Reputation: 172468

Is it possible to tell my program to run a particular function when an exception has been detected...

Yes, but the specifics depend on the platform that you are using:

Upvotes: 4

Wolfish
Wolfish

Reputation: 970

It's generally not a good idea to do this. You could, however, look at AppDomain.UnhandledException. This is pretty much restricted to one domain, and you'll also receive (potentially) notifications for all unhandled exceptions unrelated to your program.

This is usually used for class libraries, but I think with a bit of fiddle, you might get it to work.

Upvotes: 1

Related Questions