views:

254

answers:

3

Our WinForms application has been reported to occasionally just close on its own. It neither shows our own crash error submit dialog nor Windows' error submit dialog, it just closes and is gone, often when the person was afk and not doing anything with the application. It seems to be a semi-rare occurrence, maybe like 2-3 times a month, and it's happened to more than one person. I have no idea where to start with getting a repro case or where to begin tracking this down.

C# .NET 2.0 Reported cases are on Win XP

Anyone have any ideas?

+3  A: 

Exceptions will cause an app to "disappear". Check the Event logs to see if anything was there.

Check task manager to see if the process is still present when the window disappears. I have had explorer crash and fail to redraw the window until it was Alt-Tabbed or Switched-To (from task manager).

Dont put it past the users to conveniently forget they are closing the app. You may want to put some logging logic in the app to log user initiated closures. Next time it "disappears" you can check for any log entries.

StingyJack
The app isn't out in "the wild" yet so I know these users well enough to trust that they didn't close the app themselves (it happens a bit too often for convenient forgetfulness)
Davy8
Also the app doesn't create a new instance if there already is another process, and they were able to reopen the app, so it did indeed crash silently, but in general those are good things to check for.
Davy8
A: 

You could add some logic in the FormClosing event to ask the user if thats what they really want to do, you can then cancel the closing event and your application will continue to run if all is well. If you keep noticing this problem and it never performs your logic, you're going to have to get your hands dirty in the debugger.

IAmCodeMonkey
+3  A: 

Stack overflows due to infinite recursion are a big cause of apps quitting with no warning. Unless you've done something deliberate to cause a silent exit, then unhandled exceptions (other than stack overflow) will normally display some kind of UI before the app quits. Stack overflow is the most common exception (oops, sorry) to this rule.

Of course, from unmanaged or unsafe code it's almost certainly possible to upset the runtime in the right way to cause a silent exit.

The suggestions about instrumentation and looking at the Windows event log are good too.

Will Dean
It sounds like it is most likely a silent crash is the culprit. Thanks
Davy8