Search code examples
visual-studio-2012.net-4.5visual-studio-debuggingdebug-symbols

Why doesn't Debug.Assert work with 64-bit? (No Symbols Loaded)


I have reproduced this problem on two separate 64-bit machines (both running VS2012). Here's how: Create a new console application with nothing in it but this:

using System.Diagnostics;
namespace ConsoleApplication2
{   class Program
    {   static void Main(string[] args)
        {
            Debug.Assert(false);
        }
    }
}

Then, open Project settings, navigate to Build-> General -> Platform target:, and select x64 (or, alternatively, select "Any CPU", and disable the "Prefer 32-bit" setting), and run the program.

The Assertion Failed dialog appears, but hitting "Retry" doesn't break into the code, instead it just opens a "No Symbols Loaded" window, which says "Symbol loading skipped" (see screenshot below). Symbol loading for optimized module System.dll was skipped because Just My Code is enabled

If I change the Platform target to x86 (or re-enable the "Prefer 32-bit" setting), the Asserts start working properly again.

Notes:

  1. My .pdb file seems fine; breakpoints work perfectly with either setting.
  2. If I select Disable Just My Code, it still doesn't work; it just takes me to a window that says "Source Not Available."

So my question is, how do I get Debug Assertions to break into the code in a 64-bit application? (or why does disabling the "Prefer 32-bit" setting break it?)


Solution

  • I can't explain why this is happening, but, I tried this out and is breaking into the code, it's just breaking at a line deeper in the call stack:

    Stack trace upon Debug.Assert fail on 64-bit app

    If you bring up the Call Stack window you can navigate to the frame where your Debug.Assert failed.