Kelly's Space

Coding 'n stuff

JIT debugging in Windows Server 2008 R2

I have my development machine configured with Windows Server 2008 R2 (which is a great desktop OS) but certain Just-In-Time debugging scenarios that worked in previous OS versions do not work out of the box in Server 2008 R2.  Consider the following code:

        static void Main(string[] args)
        {
            if (args.Length == 1 && string.Compare(args[0], "/debug", true) == 0)
            {
                System.Diagnostics.Debugger.Break();
            }
        }

Under Server 2008 R2, this doesn’t launch the JIT debugger dialog.  If the Debugger.Break() is changed Debugger.Launch(), then the dialog is displayed. 

Another scenario that fails to show the JIT debugger is when you have an unhandled exception.  Instead of raising the JIT debugger dialog when an unhandled exception occurs, the system would just return. 

The root cause of this behavior turns out to be Windows Error Reporting (WER) getting in the way.   If you look at the registry key HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting, there is value for DontShowUI that is set to 1.  Changing this value to zero will result in a dialog like this being displayed:

I should also point out that I have Visual Studio, so I have JIT debuggers registered.  If you have the DontShowUI set, then the Debugger.Break() will also work again. 

Advertisements

One response to “JIT debugging in Windows Server 2008 R2

  1. Mike October 28, 2011 at 1:23 pm

    Thanks, I just wanted to add that I wasn’t getting my JIT Debugger to show either. However, that Registry Entry didn’t exist on my machine. I added it and set it to zero with no luck. But, setting that value to 1 fixed my JIT issue and it was now popping up.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: