【发布时间】:2010-09-08 06:47:05
【问题描述】:
作为我们产品中某些错误处理的一部分,我们希望转储一些堆栈跟踪信息。但是,我们体验到许多用户只会截取错误消息对话框的屏幕截图,而不是向我们发送程序中可用的完整报告的副本,因此我想在此对话框中提供一些最小的堆栈跟踪信息。
我机器上的 .NET 堆栈跟踪如下所示:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at LVKWinFormsSandbox.MainForm.button1_Click(Object sender, EventArgs e) in C:\Dev\VS.NET\Gatsoft\LVKWinFormsSandbox\MainForm.cs:line 36
我有这个问题:
格式看起来是这样的:
at <class/method> [in file:line ##]
但是,at 和 in 关键字,我认为如果它们运行,例如,挪威 .NET 运行时而不是我安装的英文运行时,它们将被本地化.
有什么方法可以让我以与语言无关的方式分离这个堆栈跟踪,这样我就可以只显示那些条目的文件和行号?
换句话说,我想从上面的文字中得到这些信息:
C:\Dev\VS.NET\Gatsoft\LVKWinFormsSandbox\MainForm.cs:line 36
您可以提供的任何建议都会有所帮助。
【问题讨论】:
-
我希望有人能给出解析答案,因为我正在处理来自任意应用程序的记录字符串,并且真的希望能得到一些细节。鉴于您可以控制 StackTrace 的来源,尽管您确实选择了正确的答案:)
标签: c# parsing error-handling stack-trace