Handling Contract assertions on Windows Phone 8

If you are a fan of System.Diagnostics.Contracts and use them on WP8 you may find a problem: when a contract fails, you get no clue why. Here’s how to find out. Firstly lets start with a trivial repro app, take the default WP8 project, add a using System.Diagnostics.Contracts, add a button, then this code:         void TestContract(int arg)…


Why Data Breakpoints are Disabled On Restart

Data breakpoints are both incredibly useful when you need them and yet can cause extreme pain under some circumstances. For the latter reason they are always disabled on restart, and here is why. First of what is a data breakpoint? Since at least VS2005 (maybe earlier, I forget) they are hardware breakpoints set using special…


Why Address Breakpoints Are Disabled On Restart

If you set a [native] breakpoint by address, then restart your debugger session the breakpoint will be disabled, unlike most other breakpoint types. This was a deliberate change (in VS2003 or VS2005, I forget which), and here is why. Address breakpoints are not often used if you have matching source and symbols, unless you are…


Two Fixes You Must Have for Visual Studio 2008 SP1

The SP1 release of VS08 regressed some functionality compared to the original release, in a couple of critical areas. As a result it is highly likely you’ll need the following two patches for it. I know many of our team who hit these issues, cursed, came to me (because I am the “VS guy” on…


See my early work: X-Debug from 1992

I recently discovered a floppy containing the source to a program I wrote in 1992: X-Debug, a debugger for the Atari ST. Coincidentally I also received an email via this blog from someone asking if I had the source and rights to the Atari version of HiSoft Devpac, which I wrote in the late-80s. I couldn’t…


Detecting over-Releasing on COM objects

I am in Refcount Hell right now, trying to fix a new chunk of our codebase for COM refcounting issues. Debugging missing AddRefs consumes most of my time, and I might write about that one day, but yesterday I managed to over-Release an object and of course I crashed. Finding over-Releases is trivial by comparison:…


Autoexp.dat not working in Visual Studio 2005?

As this was reported twice in the space of a week internally, I figured that external users may be hitting this too. The internal emails were along the lines of  “I added my custom types to autoexp.dat and they don’t work”. In both cases this was because they were added at the end of the…


Displaying DirectX Errors in the Debugger

Debugging DirectX calls that fail is a pain as the debugger cannot show the “nice” HRESULT codes as it does for COM errors (such as E_NOTIMPL). However you can tell the debugger about the custom error codes and add them to the [hresult] section of autoexp.dat. I went through the pain of hand calculating the…


What does "pdb is obsolete" really mean?

If your Visual Studio debugger says this to you, it either means Your PDB really is obsolete Your debugger is obsolete 1. It gets expensive in terms of testing and (sometimes) development to read every single old PDB format, so with each release the C++ team determine what is the oldest PDB they can read…


10 Years at Microsoft

I started at Microsoft the day after Labour Day, 1995 (which I soon learned was spelled Labor Day). This was about a week after the Windows 95 launch, so things were still pretty crazy on campus. It took years for the football (er, soccer) fields to recover from that, and in recent years the turf…