我有 ac# windows 应用程序(在插件架构中开发),我想从我的应用程序中记录所有未处理的异常。我能够捕获所有异常。
我想从 Exception 中读取文件名和行号。(在.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 中有任何异常我没有得到文件名和行号