Tips and Tricks From MOSS 2007 Development Training

  • General
    • do not change identity account of application pool that is used by WSS v3 from ISS mgr, change it from WSS admin site

    • if something needs to be accessible to all sites, deploy to _layout\[yourCompanyName] folder

    • get CAML IntelliSense by create a file named as sharepoint_catalog.xml contains the following

      <SchemaCatalog xmlns="http://schemas.microsoft.com/xsd/catalog">
        <Schema href="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML\wss.xsd" targetNamespace="http://schemas.microsoft.com/sharepoint/" />
        </SchemaCatalog>

      and copy this file to the following folder C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas\

    • do not change feature GUID after it's deployed and activated
    • turn on auditing only if absolutely necessary
    • do not use space with your list column names
    • use content field control instead of content edit WebPart for publishing
    • load balance your central admin site too
    • avoid custom site definition if possible - use features
    • use features and solutions to deploy WSS artifacts if possible
    • use MetaTagsGenerator to generate META tag for SEO (search engine optimization) 
  • Application Pages Customization
    • use theme if possible and meet your needs

    • do not modify the original _layout folder; make a copy of _layout folder and change your web application point to the _[your]layout folder

  • WebPart Development
    • unless you intend to use your WebPart on SharePoint 2003 site inherit your WebPart class from System.Web.UI.WebControls.WebParts.WebPart
    • deploy WebPart dll to bin folder instead of GAC [full trust] if possible
    • remember to add [assembly: AllowPartiallyTrustedCallers()] to allow the strong named assembly to run from the bin
    • remember to change trust level in web.config from "WSS_Minimal" to "WSS_Medium" or create your own policy if your WebPart uses Object Model
  • Using Object Model

class Program
{
    static void Main()
    {
        string sitePath = "http://litwareinc.com";
        // enter object model through site collection.
        SPSite siteCollection = new SPSite(sitePath);
        // obtain reference to top-level site.
        SPWeb site = siteCollection.RootWeb;

        SPWeb site1 = site; //this actually create a copy of site, I will have followup blog on this after I find out how the assignment of an reference type got a copy instead of a pointer
        site1.Dispose();   //this does not affect site          

        // enumerate through lists of site
        foreach (SPList list in site.Lists)
        {
            Console.WriteLine(list.Title);
        }
        // clean up by calling Dispose.
        site.Dispose();
        siteCollection.RootWeb.Dispose();
        siteCollection.Dispose();
    }
}