One of my most common coding task is a simple command line EXE that takes a few parameters in, opens the object model, and applies some sort of changes. Yes, I know about PowerShell, but am very comfortable with Visual Studio and Intellisense today.
Start a new “Console Application” project type
Add an assembly reference for “Microsoft.SharePoint.dll” (12.0.4518.1016)
Type “SPSite s” and right click to add the “using” statement. Very nice shortcut, thank you Joel G!
Create a new SPSite object and use the full URL to the web for the constructor
Use the SPSite.OpenWeb() method to grab that one web object without the hassle of looping through children
This trick works no matter how far the SPWeb is nested down in the site collection
It’s a best practice to have all custom code write to the event log. Every code execution should produce one and only one log entry. Exceptions (code speak for err) should be written here. For troubleshooting and support you can’t ask for a better tool. The framework exists, EventCombMT helps aggregate, and it allows you to run dozens … or hundreds … of apps while keeping a sharp eye on quality control.