Debugging tips

  • Breaking into external code: http://www.aaronlerch.com/blog/2007/08/31/tip-set-breakpoints-without-source-code-in-visual-studio-2005/ except that I tried, and it didn’t work.
  • If you don’t see the Unhandled column under Debug->Exceptions, its because Enable Just My Code is unchecked
  • To debug .net code, see this link: http://weblogs.asp.net/rajbk/archive/2010/04/21/setting-up-visual-studio-2010-to-step-into-microsoft-net-source-code.aspx
    • Check Debug->Options and Settings->General->Enable .NET Framework Source Stepping
    • Check Debug->Options and Settings->General->Enable Source Server Support
    • add http://referencesource.microsoft.com/symbols to Debug->Options and Settings->Symbols

    Once again, I can’t get any of it to work. Access is denied while trying to execute tf.exe view /version:550320 /noprompt “$/DevDiv/D11Rel/FX45RTMRel/ndp/clr/src/BCL/System/MulticastDelegate.cs” /server:http://vstfdevdiv.redmond.corp.microsoft.com:8080/devdiv2 /console > MulticastDelegate.cs.

  • To download .NET source code:

    It also pays to read the setup instructions in the included readme.txt file:

    1. Install Reference Source:
      1. Download Microsoft Reference Source Code Center from http://www.referencesource.microsoft.com.
      2. Install Reference Source to any arbitrary location say ‘C:ReferenceSource’.
    2. Setup Symbols Path:

      1. Launch Visual Studio 2008/2010.
      2. From the Tools menu, choose Options.
      3. In the Options dialog box, open the Debugging node and select General
        – Uncheck “Enable Just My Code (Managed only)”
        – Check “Enable source server support”
        – Uncheck “Require source files to exactly match the original version”
      4. Select Symbols under Debugging.
        In the Symbol File Locations box, add the downloaded symbols location: C:ReferenceSourceSymbols
        Note: To add the Symbols path Click folder icon.
        Enter in text box under ‘Cache symbols from symbol servers to this directory: C:ReferenceSourceSymbolsCache
    3. Debugging your Application
      a) Open your application code solution and build the solution.
      b) Set a break point in the code.
      c) Start debugging (press F5).

    Unfortunately, I have tried all of this and can’t get VS Debugger to break on .net source code. I kept investigating this, and finally I was able to break in when I compiled my application as a 32 bit executable. Although Question #5 on the FAQ site says you should be able to debug 64 bit code, if you run into this problem, try compiling as 32 bit (project->Properties->Debug->set Target = x86)

  • To use SOS commands from VS Immediate window, check Project->Properties->Debug->Enable Native Code debugging. Once again, doesn’t work for me.
    When I type .load sos in Immediate window, I get this error message: Error during command: extension C:WindowsMicrosoft.NETFramework64v4.0.30319sos.dll could not load (error 193). To fix this, change compiler output to 32 bit instead of 64 bit.
    See http://stackoverflow.com/questions/3547228/load-sos-extension-for-debugging
This entry was posted in Software. Bookmark the permalink.

Leave a comment