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
Thank-you for posting this!!!
ReplyDeleteYou 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!!!
No problem.
ReplyDeleteI am glad I can help :)
GREAT POST!
ReplyDeleteMillions 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
thanks. it saved me lots of time
ReplyDeleteThanks Evan
ReplyDeleteNo worries :)
ReplyDeleteafter attaching also i am unable to debug the code..
ReplyDeleteAny help welcome
reply me on praveen.sharing@gmail.com
DeleteHi Praveen,
DeleteAre you attaching the debugger to the right worker process? And have you deployed the latest code?
Cheers,
Evan