System.Diagnostics.Debug.WriteLine生产code [英] System.Diagnostics.Debug.WriteLine in production code

查看:144
本文介绍了System.Diagnostics.Debug.WriteLine生产code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也许应该已经知道了,但我不知道,我没有看到它的记录。

I should probably know this already, but I'm not sure and I don't see it documented.

我用System.Diagnostics.Debug.WriteLine经常在开发过程中能够跟踪变化的变量或异常作为我调试了code。这是为了使发展和认识的发展过程中所发生的事情更简单的。我通常要么注释掉code或删除它,当我去生产。

I use System.Diagnostics.Debug.WriteLine quite often during the development process to be able to track changes to variables or exceptions as I'm debugging the code. This is meant to make development and understanding what's happening easier only during development. I normally either comment out the code or delete it when I go to production.

我想知道如果我忘了发表意见的code发生了什么。说,例如,在开发过程中,我跟踪了可能会记录连接蜇使用Debug.Write行输出窗口的错误信息。这是在发展显然是美好的,但我想知道如果我去住,如果有危险在这里。有人可以调试器附加到我住的可执行文件和陷阱此输出?或者是它的东西,只有产生输出在Visual Studio?

I'm wondering what happens if I forget to comment the code out. Say, for example, that during the development cycle, I'm tracking error information that may log a connection sting to the output window using Debug.Write Line. This is obviously OK while developing, but I'm wondering if when I go live, if there is a risk here. Can someone attach a debugger to my live executable and trap this output? Or is it something that only produces output in Visual Studio?

又是怎么回事,当我们从调试切换到释放?这是否code获得由编译器忽略,如果我们编译的版本?

And what about when we switch from debug to release? Does this code get ignored by the compiler if we compile for release?

推荐答案

所有的Debug类成员都标有<一个href="http://msdn.microsoft.com/en-us/library/system.diagnostics.conditionalattribute.aspx">ConditionalAttribute,因此呼叫的网站将不会被编译成一个发布版本。

All the members in the Debug class are marked with ConditionalAttribute, so the call sites won't be compiled into a Release build.

这篇关于System.Diagnostics.Debug.WriteLine生产code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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