Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

Force app to crash and not show dialog box?

Is there a way to configure windows 2016 to not show this dialog box and silently crash so another app can restart it automatically?
User generated image
If not open to other suggestions
Its a legacy app we have code for if we need to edit we can.
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Sure. When an Exception happens anywhere in your application, that Exception is generally passed to an Exception Handler. It bubbles up the stack until it finds a registered handler. If it can't find a handler, then your program crashes with the above Unhandled Exception error message. Basically, it's saying that your app threw an exeption (had a problem) but there was nothing in play to catch and handle it.

Generally speaking, when writing an app, you will always have an Unhandled Exception handler of some sort. The whole purpose of that is to prevent the above error message. By the time your code reaches that handler, there's nothing you can really do to stop your app from closing, but you can at least handle it in a more meaningful way (friendly message to the user / info written to a log file / database connection closed etc.)

How you hook up an Unhandled Exception handler will depend on the dev tools you're using ( WPF / Winforms etc).
There isn't a way to prevent the message coming up other than fixing it or 'handling he exception.'
You could run in in a different session to prevent it displaying on your screen but that wouldn't stop it appearing as such as it would just appear on a different desktop session.

It may be possible to deal with the error when shown though. Many automation tools can monitor for that window and take a pre-planned action (clicking OK) to get rid of it.

if this is worth a go, try tools like Think Automation or Autohotkey etc.
SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of websss

ASKER

Thanks all
The generic unhandled exception handler sounds OK, would that be on main, and what would the catch bit look like?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- 'Chris Stanyon' (https:#a42868506)
-- 'Shaun Vermaak' (https:#a42867928)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

seth2740
Experts-Exchange Cleanup Volunteer