You finished developing your Web Part, and you pressed Crtl+Shift+B and your Build went fine, but you get errors displayed when you test your Web Part in SharePoint 2007, so what do you do now?
1. First you right-click on your project file in the solution explorer and click on “Properties”.
2. Then under the Build section you change the Output path to the bin directory in the Virtual Directory of the web application under which you want to debug your web part (this is another way to deploy your web parts besides already mentioned ways in my previous post http://dotnet.org.za/zlatan/archive/2008/03/25/developing-basic-web-parts-in-sharepoint-2007.aspx).
3. Build your project/solution (Crtl+Shift+B)
4. Next under Debug you select Attach to Process.
5. You select w3wp.exe from the list of processes (if there is more than one, then select them all just to be on the safe side).
6. I hope you didn’t forget to put a break point in your code and now debug away.