简体   繁体   English

Debug.Writeline不打印任何东西

[英]Debug.Writeline is Not printing anything

VS 2010 Pro, C#, WinForms: at the very beginning of my method I am saying Debug.Writeline("entering method blah"); VS 2010 Pro,C#,WinForms:在我的方法的最开始,我说的是Debug.Writeline("entering method blah"); then somewhere inside this method I am putting some breakpoints and run the program. 然后我在这个方法的某个地方放置一些断点并运行程序。 so I see that execution is stopped at those break points, so it is here! 所以我看到执行在那些断点处停止了,所以就在这里! but if I search the Output->Debug combobox mode and also Immediate window I cannot find the message I has written for Debug.Writeline anywhere. 但如果我搜索Output-> Debug组合框模式以及立即窗口我找不到我为Debug.Writeline写的消息。

I also tried that heck box setting in Debug options that says "Redirect all output to Immediate window"....did not help either. 我还尝试在调试选项中设置“将所有输出重定向到立即窗口”的heck框设置....也没有帮助。

Discussed already in the comments, but I wasn't sure until discussing it there. 在评论中已经讨论过,但直到那里讨论它我才确定。 However: 然而:

  • calls to Debug.Whatever(...) are typically marked with [Conditional("DEBUG")] , meaning they require the DEBUG symbol to be defined, otherwise those calls are not compiled 调用Debug.Whatever(...)通常用[Conditional("DEBUG")]标记,这意味着它们需要定义DEBUG符号,否则这些调用不会被编译
  • a default project has DEBUG and TRACE defined for the "Debug" profile, and TRACE for the "Release" profile 默认项目为“Debug”配置文件定义了DEBUGTRACE ,为“Release”配置文件定义了TRACE
  • however, you can disable the DEBUG symbol via a checkbox in "project properties" 但是,您可以通过“项目属性”中的复选框禁用 DEBUG符号

So; 所以; go to project-properties, and ensure the DEBUG symbol is defined (or not) as appropriate for your needs (for any-and-all profiles that exist in your project). 转到项目属性,并确保根据您的需要定义(或不​​定义) DEBUG符号(对于项目中存在的任何和所有配置文件)。

Make sure you press F5 to Start Debugging mode ( not Ctr + F5 ). 确保按F5键启动调试模式( 不是 Ctr + F5 )。

F5 Starting Debugging F5开始调试

CTRL + F5 Starting Without Debugging CTRL + F5无需调试即可启动

在此输入图像描述

如果Debug没有打印任何东西(并且你不能断点):你还必须检查项目属性中的“TRACE”。

If there is still no output after all, check the message types that are enabled for the output window: 如果仍然没有输出,请检查为输出窗口启用的消息类型:

  1. Right-Click inside the content area of the Output-Window. 在Output-Window的内容区域内右键单击。
  2. Make sure "Program Output" is selected for example. 例如,确保选择“程序输出”。 (It should look like the screenshot) (它应该看起来像截图)

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM