问题描述
在过去,或许现在使用的2008年之前的Visual Studio版本,我会在VB.NET代码中做这样的事情:
In the past, perhaps versions of Visual Studio prior to the 2008 that I am using now, I would do something like this in my VB.NET code:
System.Diagnostics.Debug.WriteLine("Message")
..并且输出将转到输出窗口。
..and the output would go to the output window.
现在没有。必须首先显示某些东西。
Now it doesn't. Something must first apparently be enabled.
如果这涉及到附加调试器,请说明如何做。在我看来,它应该没有太大的惊喜。
If this involves "attaching a debugger", please explain how to do it. It seems to me that it should just work without too much of a fuss.
这是一个实时解释问题的视频,并显示所有我的设置:
Here's a video explaining the issue in real time and showing you all my settings:
http://screencast.com/t/YQnPb0mJcs
我正在使用Visual Studio 2008。
I'm using Visual Studio 2008.
推荐答案
所有好的建议我注意到我没有看到这个提示,所以我会说:在你的app.config文件中,确保你没有一个< clear />
元素。
All good suggestions. I noticed that I don't see this tip mentioned, so I'll say it: In your app.config file, make sure you don't have a <clear/>
element in your trace listeners.
您将有效地清除跟踪侦听器的列表,包括默认的跟踪侦听器用于调试语句。
You will effectively be clearing the list of trace listeners, including the default trace listener used for Debug statements.
这是您的app.config文件中的内容:
Here's what this would look like in your app.config file:
<system.diagnostics>
<trace>
<listeners>
<!-- This next line is the troublemaker. It looks so innocent -->
<clear/>
</listeners>
</trace>
</system.diagnostics>
如果你想在你的app.config文件中有跟踪监听器的占位符,你应该改用如下所示:
If you want to have a placeholder for trace listeners in your app.config file, you should instead use something like this:
<system.diagnostics>
<trace>
<listeners>
</listeners>
</trace>
</system.diagnostics>
这篇关于Debug.WriteLine不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!