0

I have got a problem with a .NET application. It terminates without throwing any exception. If I start it in debug mode in my visual studio, the debugging terminates also without any error message.

I have found the post StackOverflowException in .NET which describes that this behaviour occurs when the CLR throws one the following exceptions:
- ThreadAbortException
- OutOfMemoryException
- StackOverflowException

But how can I determine which of these exception was thrown in my case?
Is it possible to log the exception and maybe to get a stack trace or the type of the exeption at least?

I have tried to write a second application, which starts the other app in a separate process. With this approach, I could detect when the process terminated, but the only information I could get in this way was the exit code -532459699. Does anyone know what that means?

Community
  • 1
  • 1
Aitch
  • 33
  • 4
  • seems COM+ related - see http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/b9328870-9ecf-4c91-9880-cfe9c577de7d/ – Yahia Jul 28 '11 at 15:49

3 Answers3

0

Try to set Visual Studio -> Debug -> Exceptions -> CLR Exceptions

sll
  • 61,540
  • 22
  • 104
  • 156
0

Did you configure Visual Studio debugger to catch all thrown exceptions? If not go to Debug/Exceptions... and check the box under the thrown column next to Common Language Runtime Exceptions

Dan Finucane
  • 1,547
  • 2
  • 18
  • 27
0

Handle the domain exceptions at the main on the program:

AppDomain.CurrentDomain.UnhandledException += OnCurrentDomain_UnhandledException;

//Add these too if you are in windows forms application
Application.ThreadException += OnApplication_ThreadException;

Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

Then if exception thrown just log it, and you can also restart your program from here without needing for another application to watch your process.

private static void OnCurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
#if DEBUG
    System.Diagnostics.Debugger.Break();//we will break here if we are in debug mode.
#endif//DEBUG

    LogException(e);
    RestartTheApplication();    
}
Jalal Said
  • 15,906
  • 7
  • 45
  • 68