Tuesday, December 14, 2010

Visual Studio 2010 debugger not stopping on SharePoint 2010 breakpoints

One of my work colleagues shared something which I think is very useful today, so I thought I should share it in here.

Occasionally, when trying to debug SharePoint 2010 codes by attaching the debugger to the w3wp.exe process, the debugger does not stop on any break points. The problem is seems to be due to Visual Studio 2010 and the version of .NET framework used.

When attaching the debugger, Visual studio by default automatically determines the code types to debug (Managed, Native, Script, T-SQL etc). With Visual Studio 2010 however, there’s now 2 Managed code types (v2.0, v1.1, v1.0) and (v4.0), because we are still using .NET 3.5 occasionally Visual Studio gets confused and automatically determines 2.0 managed code as 4.0 managed code. This causes the debugger to be successfully attached but not to stop in any breakpoints.

By setting Visual Studio to always manually debug on Managed (v2.0, v1.1, v1.0) and T-SQL seems to fix the problem. It’s been working consistently so far.

Screenshot:

Visual Studio 2010 Debugger

Have a nice day :)

Evan Putranto

9 comments:

  1. Thank-you for posting this!!!
    You resolved the problem I'd been experiencing for days! Don't know how many times I'd rebuilt, cleaned, cleared .pdbs/dlls/ASP.NET Cache and rebooted - nothing helped!
    My issue wasn't actually the .Net version, but somehow the "Automatically Detect" setting was selecting "Native Code Only" WTF!!!

    ReplyDelete
  2. GREAT POST!
    Millions of Thumbs up.
    I had a problem that only after iisreset I could debug and after stopping the debug and trying to debug again, it didn't work and I had to make an iisreset again.
    Thank you very much

    ReplyDelete
  3. thanks. it saved me lots of time

    ReplyDelete
  4. after attaching also i am unable to debug the code..

    Any help welcome

    ReplyDelete
    Replies
    1. reply me on praveen.sharing@gmail.com

      Delete
    2. Hi Praveen,

      Are you attaching the debugger to the right worker process? And have you deployed the latest code?

      Cheers,
      Evan

      Delete