如何在 Visual Studio 2010 的输出窗口中从 Console.WriteLine() 读取结果
简而言之,我只需在 Web 应用程序中添加一行:
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Console.WriteLine("Hello, world!");
}
我想要的是读取“Hello, world!”在 Visual Studio 2010 的输出窗口上,但失败了,出了什么问题?
我尝试过: 通过“工具”> 更改详细程度选项>项目及解决方案>生成并运行并更改“MSBuild 项目生成输出详细程度”的值 但没有任何效果。
To simply it, I just add one line in the Web Application:
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Console.WriteLine("Hello, world!");
}
What I want is to read "Hello, world!" on the output window in Visual Studio 2010, but failed, what's wrong?
I've tried:
change verbosity by Tools > Options > Project and Solutions > Build and Run and change values of "MSBuild project build output verbosity"
but without any effect.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
Debug.WriteLine
而不是 < code>Console.WriteLine 如果您想在调试窗口中查看结果。Use
Debug.WriteLine
instead ofConsole.WriteLine
if you want to see the result in the Debug window.您应该使用 Debug.WriteLine("Hello world") (位于 System.Diagnostics 命名空间中)输出到调试窗口。
You should use
Debug.WriteLine("Hello world")
(located in the System.Diagnostics namespace) to output to the debug window.您可以尝试 TextWriterTraceListener。查看 MSDN 帖子 - 演练:将 ASP.NET 跟踪与 System.Diagnostics 跟踪集成< /a>.
You may try TextWriterTraceListener. Have look at MSDN post - Walkthrough: Integrating ASP.NET Tracing with System.Diagnostics Tracing.