我必须承认,通常我不会费心在程序中的Debug和Release配置之间切换,我通常选择Debug配置,即使程序实际上部署在客户的位置。
据我所知,如果不手动更改,这些配置之间的唯一区别是Debug定义了Debug常量,而Release检查了优化代码。
所以我的问题实际上是双重的:
这两种配置在性能上有很大差异吗?是否有任何特定类型的代码会导致性能上的巨大差异,或者它实际上并不那么重要?
是否有任何类型的代码可以在调试配置下正常运行,但在发布配置下可能失败,或者您能否确定在调试配置下测试并正常运行的代码在发布配置下也可以正常运行。
You should never release a .NET Debug build into production. It may contain ugly code to support Edit-and-Continue or who knows what else. As far as I know, this happens only in VB not C# (note: the original post is tagged C#), but it should still give reason to pause as to what Microsoft thinks they are allowed to do with a Debug build. In fact, prior to .NET 4.0, VB code leaks memory proportional to the number of instances of objects with events that you construct in support of Edit-and-Continue. (Though this is reported to be fixed per https://connect.microsoft.com/VisualStudio/feedback/details/481671/vb-classes-with-events-are-not-garbage-collected-when-debugging, the generated code looks nasty, creating WeakReference objects and adding them to a static list while holding a lock) I certainly don't want any of this kind of debugging support in a production environment!