Windows Apps London–App Debugging Tips

This month’s meetup at the Windows Apps London group;

is all about going ‘back to basics’ and talking a little about what Visual Studio can do for app developers.

As part of that, I’m giving a short talk to try and pass on some ‘tips’ for debugging, mainly staying within the realm of .NET code for Windows/Phone apps.

I’ve written blog posts before about debugging and made a bunch of videos back in 2005 around Visual Studio 2005 which still (mostly) seem to stand the test of time so I’ll link to those here;

Debugging Videos

but there’s lots of other stuff on this website if you search for ‘debugging’

Search for Debugging

spanning across Visual Studio and WinDbg – around 70 or so posts it would seem have the word ‘debugging’ somewhere in there.

For the meetup group I put together a set of short(ish) demos of various topics that came to mind when thinking about debugging Windows/Phone apps in Visual Studio 2013. There’s no real ‘order’ to the topics and they don’t provide complete coverage of an area, they are just short illustrations of some point that came to mind when thinking about this session.

In fact, my intention at the session is to let the audience dictate which topics they want to talk about because (as always) I made over an hour’s worth of material for a session that perhaps lasts 30-40 minutes.

Given that I’ve put these 16 videos together, I thought I’d share them here and, again, in no particular order.


JIT Optimisation

Make Sure You Have PDBs

First Chance Exceptions

Native Code

Object Identities

Debugging Suspend/Resume

Debugging Background Tasks

The Threads Window is Your Friend

The Tasks Window is Your Friend

The Modules Windows is Also Your Friend

Run My App But Don’t Launch It

Crash Dumps Can Be Useful

Debugging An Installed App

XAML Visualisation (2015 CTP 5)

Performance Tips (2015 CTP 5)

Windows/Phone 8.1 Debugging: Getting a Crash Dump File From a Device

I’m writing this one down so that I don’t forget it because I’ve done it multiple times and I forget it every time Smile and it’s one of those topics that I can’t find particularly well documented on the web.

Imagine you’re testing out a Windows/Phone app on a device where it’s crashing but you can’t easily debug it. Perhaps it’s not your device.

Now, on the one hand, the Store can help with this ( as per this post ) but that’s not much help if the app isn’t in Store.

Fortunately, both Windows and Phone help you with this. I think the Windows behaviour has been there for a long time and I think the Phone behaviour is specific to V8.1 but I haven’t checked that in any great detail.

Here’s how to get it going.

Windows Phone 8.1

If you have a crashing application on Windows Phone 8.1 then it will write a crash dump to a specific location on the Phone if the settings are right. As far as I can tell, that will happen with a “vanilla” app fresh out of the Visual Studio templates whether it is built as a debug app or as a released app.

I wrote an app that has a button that runs this code;

    void OnClick(object sender, RoutedEventArgs e)
      int x = 0;
      int y = 7;
      int z = y / x;

It’s what I call “a killer app” Winking smile

First, I built this as a debug package and I deployed it to my phone. I ran it on the Phone, clicked the button and it crashed. I then looked into this folder on the Phone;


The folder was empty. However, I need to switch on a setting on the phone which I had switched off;


with that setting switched on, I re-ran the debug build of my app and caused it to crash. I looked into the same folder on the phone;


That sucks – the folder is still empty. However, I have an issue with this phone (maybe it’s all phones, I don’t know) where explorer doesn’t seem to talk to the phone properly around changes in folders. I unplugged/plugged the phone and, sure enough, there’s a dump file there;


I re-tested this with a released package of the app having first told the phone to keep more than one dump file via;


and, sure enough, I now have 2 dump files sitting in that folder (after re-plugging the phone);


and so I can now take those dump files off the phone, load them into a debugger and maybe do something with them.

Windows 8.1

On “big” Windows, there’s a document over here which explains how Windows Error Reporting is configured;

that’s a set of global settings that can be overridden at the user level via HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER respectively and it’s the big set of control switches for WER but there’s another set;

which is a smaller number of settings which, again, as far as I know can be done globally via HKEY_LOCAL_MACHINE and at a user level via HKEY_CURRENT_USER and I believe that they can also be done for an app.

At the time of writing, I have to confess that I’ve never had a tonne of success in configuring these settings the way I’d like for a Windows Store app in that I’ve never managed to configure settings specific to one app, I’ve always had to rely on the wider settings working for me.

I can’t give you the exact combination of all these settings that is going to work in your environment but I can say what has worked for me.

Firstly, let me say that I haven’t manually messed about with these settings on this PC and these are the settings that I have under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting


and under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps I then have;


so, clearly, the Windows App Cert Kit is on my machine and has set itself up a folder and it has set it up at HKEY_LOCAL_MACHINE so, effectively, it’s tried to be make a global setting.

At the user level I then have HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting;


and I have no key called  HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps.

Again, I haven’t done anything to set up these values so they are more than likely close to the defaults where they are settings rather than stored state values for WER.

With that all out of the way if I deploy a Windows 8.1 Store version of my “killer app” and cause it to crash then, sure enough, in the folder specific under the LocalDumps registry value I see a crash dump;


and, once again, I can now move that to a debugger for analysis.

Happy debugging…Smile