Thursday, May 24, 2012

Showing Console output in Windows Phone 7 Emulator

Sometimes its useful to see some debug output from the internals of your WP7 App without attaching a debugger.

One such time was this morning - where I wanted to trace the memory used in a BackroundAgent in the app I was building:


            string.Format("Peak memory usage {0}"DeviceStatus.ApplicationPeakMemoryUsage);


... and I wanted to trace that in release mode without the debugger attached.

So... to enable console output...

  • in Win32, set the registry key:

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\XDE]
    "EnableConsole"=dword:00000001
      
  • in Win64, set the registry key:

    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\XDE]
    "EnableConsole"=dword:00000001
Then use Console.WriteLine in your app.

Then restart the emulator - a console window will start along with the emulator and then the output will magically appear:


Note: if you use both Console.WriteLine  and Debug.WriteLine in your code, then both will get output when you use the DEBUG build - so you will see every message twice.

For more info, check out: http://nicksnettravels.builttoroam.com/post/2011/01/19/Windows-Phone-7-Console-Window-on-64-bit-machine.aspx and a gem hidden in the middle of http://nicksnettravels.builttoroam.com/post/2010/07/24/Howe28099s-my-Windows-Phone-7-application-being-used-Getting-started-with-the-Microsoft-Silverlight-Analytics-Framework-for-Windows-Phone-development.aspx

1 comment:

  1. Hey I like this post on WinPhone Emulator, actually had a question in reference to other information I've read on the subject. e-mail me: williams(at)dzone(dot)com

    ReplyDelete