Visual Studio 中的调试和发布有什么区别? [英] What is the difference between Debug and Release in Visual Studio?

查看:29
本文介绍了Visual Studio 中的调试和发布有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复在 .NET 中调试 Visual Studio 版本

Visual Studio 中的调试和发布有什么区别?

What is the difference between Debug and Release in Visual Studio?

推荐答案

最重要的是在 Debug 模式下没有优化,而在 Release 模式下有优化.这很重要,因为编译器非常先进,可以对代码进行一些非常棘手的低级改进.因此,您的代码的某些行可能根本没有任何说明,或者有些可能会混淆.逐步调试是不可能的.此外,局部变量通常以神秘的方式进行优化,因此 Watches 和 QuickWatches 通常不起作用,因为变量被优化掉了".还有许多其他优化.有时间试试调试优化的 .NET 代码,你就会看到.

The most important thing is that in Debug mode there are no optimizations, while in Release mode there are optimizations. This is important because the compiler is very advanced and can do some pretty tricky low-level improving of your code. As a result some lines of your code might get left without any instructions at all, or some might get all mixed up. Step-by-step debugging would be impossible. Also, local variables are often optimized in mysterious ways, so Watches and QuickWatches often don't work because the variable is "optimized away". And there are multitudes of other optimizations too. Try debugging optimized .NET code sometime and you'll see.

另一个主要区别在于,因此默认发布设置不会生成大量调试符号信息.这是您可能已经注意到的 .PDB 文件,它允许调试器找出哪些汇编指令对应于哪一行代码等.

Another key difference is that because of this the default Release settings don't bother with generating extensive debug symbol information. That's the .PDB file you might have noticed and it allows the debugger to figure out which assembly instructions corresspond to which line of code, etc.

这篇关于Visual Studio 中的调试和发布有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆