Debug.WriteLine在哪里会在C#输出到build时发布? [英] Where will Debug.WriteLine in C# output to when build release?

查看:538
本文介绍了Debug.WriteLine在哪里会在C#输出到build时发布?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我把很多Debug.WriteLine放在我的代码中进行调试。
当我准备好发布时,这些Debug.Write会影响发布版本,它们在哪里输出?

解决方案

MSDN
ConditionalAttribute属性适用于Debug的方法,支持ConditionalAttribute的编译器忽略对这些方法的调用,除非将DEBUG定义为条件编译符号,请参考编译器的文档来确定ConditionalAttribute被支持和用于定义条件编译符号的语法。



所以如果您的发行版配置不包括DEBUG符号,则在编译期间将会省略Debug.WriteLine调用将不会输出。


I put a lot of Debug.WriteLine in my code for debug purposes. When I am ready to build for release, will these Debug.Write influence the release build, and where do they output to?

解决方案

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."

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.WriteLine在哪里会在C#输出到build时发布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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