作为我们产品中一些错误处理的一部分,我们想要转储一些堆栈跟踪信息。然而,根据我们的经验,许多用户会简单地截取错误消息对话框的屏幕截图,而不是向我们发送程序提供的完整报告的副本,因此我想在此对话框中提供一些最小的堆栈跟踪信息。
我的机器上的.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
你能给出的任何建议都会很有帮助。
https://stackoverflow.com/questions/51768
复制相似问题