Environment: .NET 3.5, ASP.NET, SharePoint, WSS 3.0, VS 2008, C#
With VS 2008 comes SharePoint templates. To get to this:
Step 1: New Project-> Windows -> SharePoint (LHS) -> Click on WebPart template (RHS)
Step 2: Open the WebPart1 project
Step 3: Uncomment the C# code in WebPart1.cs in CreateChildControls()
Step 4: Save. In Solution Explorer, Right click on Deploy.
Step 5: In C:\Inetpub\wwwroot\wss\VirtualDirectories\80\web.config (aka 12-hive) do the following:
5.1 <compilation> set debug = true To enable debugging on WebPart code
5.2 <customErrors> set Off. As a dev you want to see the actual error output.
5.3 <CallStack> set True. You want to see the error stack trace to pinpoint the error
5.4 <ApplicationPageLevelTrace> set True. You want to view page level tracing
Step 6: Build, Run
Step 7: http://localhost will change to http://mossdev/default.aspx?PageView=Shared. Site Actions->Edit Mode -> Click ‘Add a Web Part’. Select WebPart1 from the list. Click Add.
Reference:
http://visualstudiomagazine.com/features/article.aspx?editorialsid=2644