Using a mini-dump for debugging (Visual Studio)

Categories: .Net   Debug   Technology   Tip   Visual Studio

[Previously on my old site]

I recently had an issue where a program wasn’t working on a server, but everything looked fine when I ran it locally. After writing a small test program, I was able to duplicate the issue and narrow it down to the few lines of code that were causing the problem.

Unfortunately, the server had a firewall that didn’t let me connect a remote debugger.  but that’s no problem: Mini Dump to the rescue!

Overall steps:

  1. In task manager, right click on your process and create a dump file.  Once it completes, it will give you the location of the file it created.
  2. Copy the file to the machine you'll be debugging from.
  3. With Visual Studio 2013 installed, double click the dump file to open it.
  4. On the right hand side, it will give an option to debug mixed(.Net) or un-managed (native) code. Click your favorite, and you have a debug session in place showing where the program is stuck.
  5. Presto!

(Variations of this functionality in previous versions of Visual Studio. It may look slightly different, but it should work. I’ve done this in VS2012 and 2013, and it has some slightly different looks, but it’s essentially the same.)

Longer version, with screen prints. This is a  dummy program that I’m doing all from the same machine, so there isn’t any need to copy from one location to another.

  1. Grab your dump from the running program in Task Manager by right clicking on it.  I created a dummy program for this that has a Console.ReadLine() in it, to force it to “hang.” Create dump file (1)

  2. After a moment, it will pop up a dialog giving the location of the dump file. Copy the file to your dev machine, or in this case, I’m on the same machine, so I just double click the .dmp in place.  Visual Studio will open.

Create dump file 2

Notice the information it gives: Names and paths to the dump files, a full callstack, and on the right, actions you can choose.

  1. Click the “Debug with Mixed” or “Debug with Managed” (depending on your version), and the program will pop-up, showing where the hanging condition is. Create dump file 3

From here, you can view the code, and maybe get some good insight to whats going on.

Note that this works with “real” executables.  If you try to do this with a program running in visual studio, with the .vshost.exe name, it doesn’t work.

Hope you find this tip handy.

Written on November 23, 2013