Visual Studio Debug & Release Mode

It's useful to know the difference between debug and release build configuratioins in Visual Studio.

Visual Studio Debug & Release Mode

In debug configuration, your program compiles with full symbolic debug  information and no optimization. Optimization complicates debugging,  because the relationship between source code and generated instructions  is more complex (from MSDN).

So what does that mean? well look at the stack trace in these three scenarios. This was a very simple demo I put together of multiple methods calling each other.

The first is you see the normal full stack trace you see in debugging mode.

The second shows the stack trace when built in release mode, but notice it also has a PDB file. If this is shiupped with the released DLL then you get minimal stack trace.

Without the PDB you don't get much that helps with debugging.

You can edit and create your own build configurations if you really want to. See MSDN here. I've never had the need to, but I suppose you may want to choose your own set of optimisations. Details of those are here.

Testing

When it comes to testing, you should really test with both configurations. There are many optimisations in Release mode which may introduce quirks, but you may not have tested all paths through code if your team uses pre-processor directives such as

#if DEBUG
    Console.WriteLine("Debug version");
 #endif