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