By: Kathryn Bartlett
Earlier this year we discussed debugging by creating a Notes Column, a Notes List, using DateTime. Now, and by using Version counts. This article can be accessed here. In this article, we will discuss yet another way called “Attaching to Process” using the Visual Studio 2010 debugger.
Step 1: Insert Breakpoints in your C Sharp Code
In Visual Studio 2010, insert breakpoints in your C Sharp code where you want to begin stepping through. You can do this either by clicking to the left of the window where your code resides (circled in red below) or by right-clicking the line you wish to insert a breakpoint at, expanding the “Breakpoint” menu, and clicking “Insert Breakpoint”.

Step 2: Attaching to Process
In Visual Studio 2010, go to the “Debug” menu, and click “Attach to Process”.

Check the two checkboxes circled below.

Step 3: Select the Appropriate Process
Select the appropriate processes and keep clicking attach until all the processes have been attached. To attach to SharePoint 2010, the correct process is w3wp.exe. Select all the w3wp.exe processes visible in the list, and click “Attach” until the dialog above disappears from the screen. Selecting this process will attach to all site, list, and item event receivers in addition to workflows. To attach to a timer job, the process to attach to is OWSTIMER.EXE.
Step 4: Run the Code via SharePoint
Next, go to your SharePoint site and run the code you wish to test. The breakpoint in Visual Studio should become highlighted in yellow. If the breakpoint doesn't get hit, redeploy your code from Visual Studio 2010; the code you are stepping through must be the most recent version deployed to your SharePoint server.
By: Kathryn Bartlett