Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 VS2010 开发我的项目。在我的代码库中,我使用了 stackframe 的GetFileLineNumber()函数。但是,在运行时,它总是返回0. 即使我正在运行调试版本,也会发生这种情况。我还确认生成的 pdb 文件与生成的可执行文件一起存在。
GetFileLineNumber()
0
有任何想法吗?
啊哈!我发现信息隐藏在 MS 参考帖子的底部:
http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe.getfilelinenumber(v=vs.80).aspx
原来你必须像这样构造你的 StackTrace 实例:
st = new StackTrace(true);
获取文件和true线路信息。
true