Debug.WriteLine 不工作 [英] Debug.WriteLine not working
问题描述
过去,也许是我现在使用的 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 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!