Windows Phone: Log to console
Asked Answered
U

2

9

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?

Upthrow answered 12/1, 2013 at 3:2 Comment(0)
R
9

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

Rhino answered 12/1, 2013 at 18:10 Comment(0)
L
-1

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

Lubberly answered 12/1, 2013 at 3:43 Comment(1)
System.* namespace isn't available from WP8 C++ AFAIK. Only Windows.* WinPRT APIs and C++ functions should be available. But I could definitely be wrong here.Rhino

© 2022 - 2024 — McMap. All rights reserved.