Windows Phone: Log to console

丶灬走出姿态 提交于 2019-12-29 07:32:09

问题


Disclaimer: I'm quite new to the MSFT tech world and only started Windows Phone development a month or so ago.

I am unable to figure out how to log information to the Visual Studio Output window from within a C# and C++ (Direct3D) Windows Phone 8 App. Is this possible?

I am building in debug mode, targeting Windows Phone 8, running in the XDE emulator and my development machine is a Windows 8 box with VS2012 Ultimate installed. My App runs fine, my Direct3D scene renders normally, but I can't log anything! This makes tracing code execution difficult and forces me to use breakpoints (which can be overkill in many situations).

I've been searching far and wide and have tried many methods (OutputDebugString being one of them). I can't see anything on MSDN about this - why is this not documented anywhere?


回答1:


Yep, it's possible to write debug strings from WP8 C++ to the output window in VS2012. I actually have an example of that here.

1) Invoke OutputDebugString from C++.

void Direct3DInterop::MyButtonWasClicked()
{
    OutputDebugString(L"Button was clicked!");
} 

2) Before running the app make sure to change to the native debugger from the managed debugger in the project's properties.




回答2:


I believe the methods in System.Diagnostics.Debug (specifically the overloads of WriteLine()) work...although I haven't tried them with C++ apps.



来源:https://stackoverflow.com/questions/14289770/windows-phone-log-to-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!