写堆栈跟踪时,一个异常是从另一个线程抛出

编程入门 行业动态 更新时间:2024-10-22 19:25:29
本文介绍了写堆栈跟踪时,一个异常是从另一个线程抛出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我怎么能写一个未处理的异常(从任何线程抛出)的堆栈跟踪到一个文件?

How can I write the stack trace of an unhandled exception (thrown from any thread) to a file?

我需要这个来帮助调试挂程序。

I need this to help debug a hanging application.

推荐答案

感谢你的一切,但我已经看到了,我在运行程序从Visual Studio一丝认为写的是.NET控制台窗口中的输出时,当从被抛出任何线程未处理的异常不重定向到控制台窗口。

Thanks you all, but I have seen that when I running the program from Visual Studio the output of trace that is written by .NET to the console window when an unhandled exception from any thread is thrown is not redirected to the console window.

这只是重定向当我运行从Visual Studio分离的节目。 所以这个code是挺好看的所有堆栈跟踪从抛出未被处理的异常任何线程

It is just redirected when I run the program separated from Visual Studio. So this code is very good to see all stack trace from any thread that throws an exception which is not handled

Trace.Listeners.Clear(); TextWriterTraceListener twtl = new TextWriterTraceListener(Path.Combine(Environment.CurrentDirectory, "logfile.txt")); twtl.Name = "TextLogger"; twtl.TraceOutputOptions = TraceOptions.ThreadId | TraceOptions.DateTime | TraceOptions.Callstack; ConsoleTraceListener ctl = new ConsoleTraceListener(false); ctl.TraceOutputOptions = TraceOptions.DateTime; Trace.Listeners.Add(twtl); Trace.Listeners.Add(ctl); Trace.AutoFlush = true;

更多推荐

写堆栈跟踪时,一个异常是从另一个线程抛出

本文发布于:2023-11-11 23:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579844.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:堆栈   是从   线程   抛出   异常

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!