[英]Where will Debug.WriteLine in C# output to when build release?
I put a lot of Debug.WriteLine in my code for debug purposes. 我在我的代码中放了很多Debug.WriteLine用于调试目的。 When I am ready to build for release, will these Debug.Write influence the release build, and where do they output to?
当我准备构建发布时,这些Debug.Write会影响发布版本,它们输出到哪里?
Debug.WriteLine
is annotated with the Conditional
attribute. Debug.WriteLine
使用Conditional
属性进行批注。 (see MSDN ) (见MSDN )
The ConditionalAttribute tells the compiler not to generate that code unless the DEBUG
flag is supplied. 除非提供了
DEBUG
标志,否则ConditionalAttribute告诉编译器不要生成该代码。
From MSDN : "The ConditionalAttribute attribute is applied to the methods of Debug. Compilers that support ConditionalAttribute ignore calls to these methods unless "DEBUG" is defined as a conditional compilation symbol. Refer to a compiler's documentation to determine whether ConditionalAttribute is supported and the syntax for defining a conditional compilation symbol." 从MSDN :“ConditionalAttribute属性应用于Debug的方法。支持ConditionalAttribute的编译器忽略对这些方法的调用,除非”DEBUG“被定义为条件编译符号。请参阅编译器的文档以确定是否支持ConditionalAttribute和语法用于定义条件编译符号。“
So if your release configuration does not include DEBUG symbol the Debug.WriteLine calls will be omitted during compilation and there will be no output. 因此,如果您的发行版配置不包含DEBUG符号,则在编译期间将忽略Debug.WriteLine调用,并且不会输出。
如果将它们切换到Trace.WriteLine
,则可以在app / web.config文件中定义任意侦听器。
Debug.Writeline未编译为发布代码。
我相信它会被编译出来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.