在Visual Studio调试和发布之间的区别是什么?区别、Visual、Studio

2023-09-02 11:30:00 作者:爱囚 Raging

可能的复制   调试的Visual Studio版本的.NET

什么是调试之间的区别,并释放在Visual Studio?

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

推荐答案

最重要的是,在调试模式下,没有优化,而在发行方式有优化。这很重要,因为编译器是非常先进的,可以做你的code一些pretty的棘手低级别的改善。这样一来你的code的某些行可能会离开,没有任何说明的全部或部分可能会都混在一起。一步一步的调试是不可能的。此外,局部变量往往优化以神秘的方式,让手表和QuickWatches往往不工作,因为变量是优化掉。而且,还有其它的优化群众过。尝试一段时间的调试优化的.NET code,你会看到的。

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文件,你可能已经注意到,它允许调试器来找出哪些汇编指令corresspond的code等,以该行。

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.