Tracking down exceptions in Visual Studio 2008

If you ever looked at Visual Studio's Output window and saw a "first chance exception" message and a weird error which is not even documented in the MSDN, and you were not patient enough to debug step by step until the line popped up in the Output window again, I have a solution for you. It also applies if you want the Visual Studio debugger to break every time an exception is thrown and/or unhandled by your code.

The secret is Visual Studio's Debug->Exceptions dialog. Here we can check which exceptions to track down, including .NET, native C++, ATL and stuff.

In the particular case of C++ exceptions, for this mechanism to work, certain conditions must be met:

  1. When installing Visual Studio, the C++ runtime was installed
  2. In the C++ project's general properties, "Use of MFC" is set to "Use MFC in a static library" or "Use Standard Windows Library".
  3. In the project's properties, section C/C++->Code Generation, "Runtime Library" is set to "Multi-threade" or "Multi-threaded Debug" (not DLL!).

A million thanks to Eric Haddan from the MSDN forums

Comments

Popular posts from this blog

VB.NET: Raise base class events from a derived class

Apache Kafka - I - High level architecture and concepts

Upgrading Lodash from 3.x to 4.x