使用Debugger.Launch时,Visual Studio中的控制台输出未显示 [英] Console output not shown in Visual Studio when using Debugger.Launch

查看:242
本文介绍了使用Debugger.Launch时,Visual Studio中的控制台输出未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过System.Diagnostics.Debugger.Launch()(或等效地通过使用VS来附加到现有进程)来调试C#.NET应用程序。因为我不会进入,我需要从Windows资源管理器而不是从Visual Studio中调用该应用程序。

I'm attempting to debug a C#.NET application by means of System.Diagnostics.Debugger.Launch() (or equivalently, by using VS to attach to an existing process). For reasons I will not get into, I need to invoke the application from Windows Explorer rather than from within Visual Studio.

虽然几乎一切都正常,我发现当调试器以这种方式连接时,即VS输出窗格不显示任何控制台消息(即pinvoke'd非托管DLL中的Console.WriteLine(),printf()等)。如果我从Visual Studio中启动调试会话,则所有控制台消息按预期显示在输出窗格中。

While almost everything works fine, I've found that the VS Output pane doesn't display any console messages when the debugger is attached in this way (i.e. Console.WriteLine(), printf() in pinvoke'd unmanaged DLLs, etc). If I launch the debug session from within Visual Studio, all console messages appear in the Output pane, as expected.

所以问题是:如何附加VS调试器到现有的进程,但仍然可以在VS输出窗格中看到控制台输出?

So the question is: how can I attach the VS debugger to an existing process, but still be able to see console output in the VS output pane?

编辑:我已经尝试检查将所有输出窗口文本重定向到立即窗口在VS选项中;没有任何区别。

I have tried checking "Redirect all Output Window text to the Immediate Window" in the VS options; it made no difference.

推荐答案

另一个选择是将Console.Out流设置为FileStream,并输出内容到档案。

Another option would be to set the "Console.Out" stream to a FileStream, and output the content to a file.

这篇关于使用Debugger.Launch时,Visual Studio中的控制台输出未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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