Debugging SharePoint 2010 Web Parts from Visual Studio 2010 :
For debugging your web part in SharePoint 2010, you should follow below steps as given:
- Deploy your Web Part
- Add the Web Part to Page
- In your code, create a break point.
- Go to “Debug” menu, and choose “Attach to Process”.
- Under “Attach to:” section, click on “Select …” button.
- Check the “Show processes in all sessions” checkbox.
- Select all “w3wp.exe” Processes, then click on the “Attach” button.
- Run your page that contains the Web Part. You should now hit your break point, and will be able to step through your code.