Debugging SharePoint 2010 Applications

One common problem many people run into is debugging SharePoint 2010.  Not just dealing with the many nuances, but actually just the simple task of attaching a debugger.  Sometimes, you’ll go through the hassle of finding the right worker process, attach to it, and even though you are 100% certain the binaries you have recently complies are currently what’s running on the site, you don’t get the satisfaction of your red breakpoint completely filling in.  You stare at the screen blankly in confusion.  Confusion turns to rage.  Rage turns into sadness.  Sadness turns into acceptance.  You reset IIS, reload the page, and try again.  And suddenly, it works.  If the definition of insanity is doing the same thing over and over and expecting a different result, SharePoint really does make you crazy, because it rewards such nonsensical persistence with different results.

Today, my friends, I shall show you a little trick that will remove a little bit of crazy from your life: How to attach to SharePoint 2010 (2007 should apply as well) 100% of the time every time.

Step 1: Click Debug -> Attach to Process


Step2: Change process type you’re attaching to


Step 3: Select Managed (v2.0, v1.1, v1.0).


Step 4: Select your worker process, and attachImage

The trick here, is for whatever reason, when left to its own devices, Visual Studio assumes that your 2.0 Application Pool (you ARE using a 2.0 app pool with SharePoint, right?!) is actually 4.0, and never successfully attaches.  By forcing it to attach using the older symbols, your life will remain happier, your hairline fuller, and your coworkers may be able to remove the Suicide Watch hotline number from speed dial.

Happy coding!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s