【发布时间】:2014-01-26 07:01:36
【问题描述】:
我有一个 c# windows 应用程序(在 Plugin Architecture 中开发),我想从我的应用程序中记录所有未处理的异常。 我能够捕获所有异常。
我想从异常中读取文件名和行号。 (在 .Net 2.0 中)
我用过
if (exception.InnerException != null)
{
exception = exception.InnerException;
}
StackTrace trace = new StackTrace(exception, true);
string fileName = trace.GetFrame(0).GetFileName();
int lineNo = trace.GetFrame(0).GetFileLineNumber();
它在我的应用程序中的异常情况下工作正常,如果引用 dll 中的任何异常我没有得到文件名和 lineNumber
【问题讨论】:
-
我在想一些事情,要么记录每一帧,要么遍历帧,直到找到来自代码的帧
标签: c# exception .net-2.0 stack-trace plugin-architecture