.NET 发布模式构建中是否提供堆栈跟踪信息?
如果我选择发布模式来构建 dll,堆栈跟踪信息仍然可用吗?
如果是这样,那么哪些信息在发布模式下不可用?
If I choose release mode to build a dll, is the stacktrace information still available?
If so, then what information is unavailable in release mode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在异常上下文中引用堆栈跟踪,那么是的,堆栈跟踪信息在发布模式下仍然可用。在发布模式下丢失的是完整的调试符号,它为堆栈跟踪提供源代码序列点信息。这允许堆栈跟踪识别特定堆栈跟踪条目引用的特定代码行。
此外,在启用优化的发布模式下,代码可能会被内联,从而改变运行时代码的结构。虽然绝对更优化,但运行时发布代码与实际编写的代码行关系不大。
If you are referring to stack traces in the context of Exceptions, then yes, stack trace information is still available in release mode. What you lose in release mode is full debug symbols, which provide source code sequence point information to stack traces. This allows the stack trace to identify the specific line of code that a particular stack trace entry refers to.
Additionally, in release mode with optimizations enabled, code may be inlined, changing how the runtime code is structured. While definitely more optimal, runtime release code has less of a relationship with the line of code that were actually written.
您始终拥有堆栈跟踪信息(这是与构建模式无关的运行时功能),但行号和源文件名通常在发布构建堆栈跟踪中不可用。
您可以通过更改构建配置来创建完整的程序数据库 (.pdb) 文件,从而在发布构建堆栈跟踪(包括异常情况)中获取行号和源文件名。要在 Visual Studio 中执行此操作:
请注意,只有当 .pdb 文件与您的应用程序一起部署时,这才会有帮助。
You always have stack trace information--that's a runtime feature unrelated to the build mode--but line numbers and source file names are normally unavailable in release build stack traces.
You can get both line numbers and source file names in release build stack traces (including in exceptions) by altering the build configuration to create full program database (.pdb) files. To do so in Visual Studio:
Note that this will only help if the .pdb files are deployed alongside your application.