.NET 中“调试”和“发布”构建之间的主要区别是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/733840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:29:27  来源:igfitidea点击:

What is the key difference between a 'Debug' and a 'Release' build in .NET?

.net

提问by Dhana

Duplicate of:Debug vs. release in .NET

重复:.NET 中的调试与发布

Why are there 'Debug' and 'Release' modes on build in .NET applications?

为什么在 .NET 应用程序中构建有“调试”和“发布”模式?

What is the major technical difference between them?

它们之间的主要技术区别是什么?

回答by Andrei R?nea

Differences:

区别:

  • Debug inserts NOPs (No-operation CPU instructions) between useful CIL code in order to allow debugger attachment
  • Debug does not allow various optimizations:
    • Inlining (placing a method's code in place of a call to it in order to reduce call overhead)
    • Loop unrolling (replacing a loop code - such as a for - with the repeated code to eliminate loop overhead (loop variable maintenance))
  • 调试在有用的 CIL 代码之间插入 NOP(无操作 CPU 指令)以允许调试器连接
  • 调试不允许各种优化:
    • 内联(放置一个方法的代码来代替对它的调用以减少调用开销)
    • 循环展开(用重复代码替换循环代码 - 例如 for - 以消除循环开销(循环变量维护))

And many others. Release is sensibly faster, but it offers no real debug support. For debugging there is... the debug mode :)

还有许多其他人。Release 明显更快,但它不提供真正的调试支持。调试有......调试模式:)

回答by Chris B

A short answer is that code built in 'Release' mode will be optimised for speed or size and also will have all the information used for debugging removed

简短的回答是,在“发布”模式下构建的代码将针对速度或大小进行优化,并且还将删除用于调试的所有信息

回答by Sidhartha Shenoy

Yeah right, you can even debug in release mode [:)]. There are elaborate processes to do it.

是的,您甚至可以在发布模式下进行调试 [:)]。有详细的流程可以做到这一点。

However, the release build is optimized for speed and performance. Also the Microsoft End user licence agreement states that you cannot deploy your debug files on a client system.

但是,发布版本针对速度和性能进行了优化。此外,Microsoft 最终用户许可协议规定您不能在客户端系统上部署调试文件。

http://www.codeproject.com/KB/debug/releasemode.aspx

http://www.codeproject.com/KB/debug/releasemode.aspx

回答by Anirudh Goel

The main difference as I understand it is that in Debug Mode the whole symbol information which is used by the debugger is stored along with the program, so that if a developer wants to debug the application before releasing he/she may do so, by attaching to any debugger.

据我所知,主要区别在于在调试模式下,调试器使用的整个符号信息与程序一起存储,因此如果开发人员想在发布之前调试应用程序,他/她可以这样做,通过附加任何调试器。

You might've noticed the .pdb files in the debug folder. Also the size of the executable is fairly larger. However in Release mode, the debugger symbol information is omitted assuming that the end user is going to use the application so he must not be provided with the application symbols.

您可能已经注意到调试文件夹中的 .pdb 文件。此外,可执行文件的大小相当大。然而,在发布模式下,假定最终用户将使用应用程序,调试器符号信息将被省略,因此不得向他提供应用程序符号。

You can think of the symbols as the information provided to the debugger to understand what local variables, what functions, where breakpoints are set and all sorts of information so that it can precisely tell you what part of code is being executed currently.

您可以将符号视为提供给调试器的信息,以了解哪些局部变量、哪些函数、在哪里设置断点以及各种信息,以便它可以准确地告诉您当前正在执行哪部分代码。