Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone: Log to console

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?

like image 296
aaronsnoswell Avatar asked Jan 12 '13 03:01

aaronsnoswell


1 Answers

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.

Native debugger in the project's properties

like image 197
JustinAngel Avatar answered Sep 18 '22 08:09

JustinAngel