par*_*oir 3 .net c# debugging stack-trace visual-studio
我在生产中有一个.NET Windows应用程序无法访问Visual Studio(标准版),他们唯一可以安装的是Express版本,它没有Just-In-Time Debugging选项(崩溃时有调试按钮).所以我只是想知道是否有一个Windows应用程序调试工具或其他我可以运行或附加的东西来查看stacktraces.我还在我的应用程序中启用了PDB,但它不提供任何更多信息,因此我可以跟踪我的崩溃(由未处理的异常引起).
如果要捕获异常,则Exception对象包含堆栈跟踪:Exception.StackTrace.此外,您可以使用Environment.StackTrace访问它.
在下面的代码中,还有一个未处理异常的事件处理程序,它将异常(包括堆栈跟踪)写入事件日志.
// Sample for the Environment.StackTrace property
using System;
class Sample
{
public static void Main()
{
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(UnhandledExceptions);
Console.WriteLine("StackTrace: '{0}'", Environment.StackTrace);
throw new Exception("Fatal Error");
}
static void UnhandledExceptions(object sender, UnhandledExceptionEventArgs e)
{
string source = "SOTest";
if (!System.Diagnostics.EventLog.SourceExists(source))
{
System.Diagnostics.EventLog.CreateEventSource(source, "Application");
}
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.Source = source;
log.WriteEntry(e.ExceptionObject.ToString(),
System.Diagnostics.EventLogEntryType.Error);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7666 次 |
| 最近记录: |