如何从本机Windows服务将跟踪消息发送到VS输出面板 [英] How to send trace messages to VS output panel from a native windows service

查看:104
本文介绍了如何从本机Windows服务将跟踪消息发送到VS输出面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个使用本机C ++ dll的托管Windows服务.
我正在使用Debugger.Launch()启动VS(2010)调试器,我
能够附加到服务并调试非托管代码.
当我从托管代码(System.Diagnostics.Trace)输出跟踪消息时

Hi,
I have a managed windows service that uses a native C++ dll.
I'm launching the VS (2010) debugger using Debugger.Launch() and i'm
able to attach to the service and debug the unmanaged code as well.
When i'm outputting trace messages from the managed code (System.Diagnostics.Trace)

它们显示在输出窗口很好,但是我找不到任何方法 代码.

they are displayed in the output window just fine, however i couldn't find any way to do the same from the unmanaged code.

我尝试过:
_CrtDbgReport()
ATLTRACE()
OutputDebugString()

他们都没有工作.消息未显示在调试器的输出"窗口中.
有谁知道该怎么做?
谢谢!

I tried:
_CrtDbgReport()
ATLTRACE()
OutputDebugString()

none of them worked. The messages were not displayed in the debugger's output window.
Anyone knows how this can be done?
Thanks!



推荐答案

OutputDebugString 函数对我而言效果很好,两者都可以通过按F5键从Visual Studio运行,并将Visual Studio附加到正在运行的进程.在里面 输出窗口,请确保"显示来自以下位置的输出:" drowdown有 选择了调试,均未选择 构建构建顺序.

OutputDebugString function works well on my side, both running from Visual Studio by press F5, and attach Visual Studio to the running process. In the Output window, please make sure the "Show output from:" drowdown has Debug selected, neither Build or Build Order.

 

这是我的测试代码:

 

int _tmain(int argc,_TCHAR * argv [])

int _tmain(int argc, _TCHAR* argv[])

{

for(int i = 0; i< 10; i ++)

for(int i = 0 ; i < 10 ; i++)

{

//getchar();

//getchar();

OutputDebugString(L"a");

OutputDebugString(L"a");

}

返回0;

}


这篇关于如何从本机Windows服务将跟踪消息发送到VS输出面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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