2011-07-28 131 views
0

我遇到了.NET应用程序的问题。 它终止而不会引发任何异常。如果我在Visual Studio的调试模式下启动它,调试终止也没有任何错误消息。异步.NET异常

我发现它描述的是,当CLR抛出一个以下例外出现这种情况后StackOverflowException in .NET
- ThreadAbortException
- OutOfMemoryException异常
- StackOverflowException

但我怎么能确定这些异常被扔在我的案件?
是否有可能记录异常,并可能至少得到一个堆栈跟踪或类型的exeption?

我试图编写第二个应用程序,它在一个单独的进程中启动另一个应用程序。通过这种方法,我可以检测到进程何时终止,但我可以通过这种方式得到的唯一信息是退出代码-532459699。有谁知道这意味着什么?

+0

似乎COM +相关 - 见http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/b9328870-9ecf-4c91-9880-cfe9c577de7d/ – Yahia

回答

0

尝试设置Visual Studio -> Debug -> Exceptions -> CLR Exceptions

0

你配置Visual Studio调试器来捕获所有抛出的异常? 如果没有去调试/例外...,并选中抛出列下旁边的公共语言运行库异常

0

处理的程序在主域例外:

AppDomain.CurrentDomain.UnhandledException += OnCurrentDomain_UnhandledException; 

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

Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); 

那么,如果异常抛出只记录它,你也可以从这里重新启动你的程序,而不需要另一个应用程序来观察你的过程。

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();  
}