在发布模式下显示 .NET 程序集的堆栈跟踪中的行号
有没有办法在发布模式下显示 .NET 程序集构建/部署的堆栈跟踪中的行?
更新:
我的应用程序分为三个类库项目和一个 ASP.NET“网站”项目。 我试图追踪的错误位于三个类库项目之一中。 我只为生成“对象引用未设置到对象实例”错误的类库项目部署了 pdb 文件。
行号仍然没有显示在堆栈跟踪中。 我是否需要为所有项目部署 pdb 文件才能获取堆栈跟踪中的行号?
工作解决方案
为每个应用程序部署 pdb 文件修复了行号问题。
Is there a way to display the lines in the stack trace for the .NET assembly build/deployed in Release mode?
UPDATE:
My application is divided into three class library projects and one ASP.NET "website" project. The error I am trying to track down is in one of the three class library projects. I only deployed the pdb file for the class library project that is generating the "Object reference not set to an instance of an object" error.
The line numbers are still not showing up in the stack trace. Do I need to deploy the pdb files for all projects to get the line numbers in the stack trace?
Working solution
Deploying the pdb file for each application fixed the line number issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
检查 DEBUG 常量参数。使用下面的注释实现:
Check the DEBUG constant parameter.Implemented with the comment below:
在 VS2012 中,您还需要在属性的“打包/发布 Web”部分中取消选中“排除生成的调试符号”。
In VS2012 you need to uncheck "Exclude generated debug symbols" in the Package/Publish Web section of the properties as well.
我的解决方案
将 pdb 文件复制到可执行文件的同一文件夹中。
现在我可以在运行exe文件时查看行号。
这就是
http://msdn.microsoft 的原因。 com/en-us/library/ee416588%28v=vs.85%29.aspx
My solution
Copy pdb file in same folder that executable file.
now i can view the line number when run the exe file.
this is reason
http://msdn.microsoft.com/en-us/library/ee416588%28v=vs.85%29.aspx
我过去遇到过一些问题,我觉得需要使用发布版本来部署 PDB 文件才能跟踪错误。 原因是,就像你说的,异常发生在一个非常大的方法中,我无法准确地确定它发生在哪里。
这可能表明该方法需要重构为更小、更细粒度的方法。 没有一个万能的答案,但这种方法在短期内(我经常在重构过程中发现错误)和长期来看都对我很有帮助。
只是一个想法。
I've run into problems in the past where I feel the need to deploy PDB files with a release build in order to track down an error. The reason is, like you said, was that the exception occurred in a method that was very large and I could not accurately pinpoint where it was happening.
This might be an indication that the method needs to be refactored into smaller, more granular methods. Not a one size fits all answer, but this approach has served me well in the short term (I've often found the bug during the refactoring) and in the long run.
Just a thought.
在构建/部署包中包含调试符号。
Include debug symbols with your build/deployment package.
在 VS 2008 Express 中,我在“项目属性”下找到了它 --> 编译--> 高级编译选项。
In VS 2008 Express, I found it under Project Properties --> Compile --> Advanced Compile Options.
在 .NET Core 中,您需要关闭发布模式的“优化代码”选项才能显示正确的行号。
控制代码的 C# 编译器选项一代
In .NET Core you need to turn off 'Optimize code' option for release mode to show the correct line number.
C# Compiler Options that control code generation
这每次都有效。 您只需对堆栈跟踪消息进行子字符串化即可。 真的很简单! 另外,在 vb.net 中,您确实需要执行“显示所有文件”并包含 pdb。
C# 版本:
This works every time. You just need to substring the stack trace message. Real Easy! Also, in vb.net you do need to do the "Show All Files" and include the pdb.
C# version: