Net application crashes unexpected without exception?

Try AppDomain. UnhandledException Application. ThreadException only raises when an exception occurs on the UI threads.

Try AppDomain. UnhandledException. Application.

ThreadException only raises when an exception occurs on the UI threads.

If you use TCP/IP then you are quite likely using threads. If a thread dies with an unhandled exception, very common when calling EndXxxx(), then your app terminates. This may be silent if Windows Error Reporting is turned off on the machine, not uncommon on servers.At least catch ObjectDisposedException so you can deal with a connection that abruptly disconnects or is closed forcibly.

And yes, write an event handler for AppDomain.CurrentDomain. UnhandledException, subscribe it in your Main() method. Log or display the value of e.ExceptionObject.ToString() so you can tell exactly what it is dying on.

When a . Net application suddenly exits without any error prompts or the unhandled exception handlers firing then it's very likely that your application is encountering a stack overflow. This will quickly terminate the process in many cases without running any handlers.

– John Saunders Dec 15 '10 at 19:40 @John, it should show up in the event log but it will just say "stack overflow". I've found that WinDbg is generally better than VS here that it will break and give you a chance to see the stack while VS is more likely to just exit suddenly while debugging. – JaredPar Dec 15 '10 at 19:43 I expected something in the event log, but the OP said there was nothing.

Which event source, id and log would be used? – John Saunders Dec 15 '10 at 19:44 @John I don't believe that an entry in the event log is guaranteed. But this is an area that I don't have a lot of depth in – JaredPar Dec 15 '10 at 19:49.

This never happens. Not ever. Either you are catching and ignoring an exception and then returning, or perhaps you are running some non-managed code which is causing an access violation of some kind.

But . NET applications don't "just quietly exit". Running in windbg is a good idea, as it should show unmanaged exceptions, and perhaps debug output.

I had a situation once where running a . NET application under a tool that handles unmanaged code showed debug output from the C runtime library - we were calling an unmanaged DLL which was said to be thread-safe, but it wasn't. Using it from multiple threads caused the C runtime heap to be trashed.

C was yelling about that, but nobody was listening!

1 It does happen for stack overflows – JaredPar Dec 15 '10 at 19:42.

I've had this issue. I'd written a . Net application which was performing keystroke emulation on other applications.

I'd leave it running all night hoping to find it having done all my work by the morning. It was just gone. It wrote a log every time it entered and exited a routine so I could see exactly what it had done.

Nothing, no exception logging. Just work work work work work. And then, Nothing.

Turns out it was because I was using a bunch of API calls and I was calling them very frequently. This was causing some kind of memory leak, presumably in my application's workspace. The way I resolved it was by writing another .

Net application (application 2) which started up the crashing one (application 1). After so long application 1 would terminate itself but shell application 2 just before. Application 2 would then start application 1 back up.

And so on and so on, until all the work got done! Messy and frustrating but ended up working quite beautifully :) I'm sure there's a much much much better way of doing this. I was probably not marshaling my COM API calls properly or whatever.

But it seems that shutting the app down and restarting it was releasing the memory (along with the leaks) and letting it start afresh. Perhaps no use in your cirsumstance but that's my story. Amen.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions