Stuart Cox’s Tech Punch

Entries from April 2009

SharePoint 2007 100% CPU Spike – Blue Screen 0×0000001d

April 29, 2009 · 1 Comment

Problem

SharePoint 2007 Web Front End (WFE) servers crashing repeatedly.  Environment is SharePoint 2007 (MOSS Enterprise) 64-bit running on Windows Server 2008 Standard.  Server was crashing repeatedly with CPU spiking to 100%, blue screen, and server rebooting itself.  System log showing BugCheck event (1000) entry with code 0×0000001d:

The computer has rebooted from a bugcheck.  The bugcheck was: 0×000000d1 (0xfffff9802ea0ef50, 0×0000000000000002, 0×0000000000000000, 0xfffffa6004e06ed9). A dump was saved in: C:\Windows\MEMORY.DMP.

Resolution

After a lot of troubleshooting, it turns out it was Trend Micro Common Firewall Driver (Trend Micro OfficeScan Client 8.0).  When we disabled the firewall, problem resolved.

  del.icio.us it! digg it! reddit! technorati! yahoo!

Categories: MOSS 2007 · SharePoint · WSS 3.0 · Windows Server 2008

Visual Studio 2008 Workflow Project Wizard – SharePoint Not Installed

April 20, 2009 · 1 Comment

Problem:

I’m creating a SharePoint Sequential Workflow using Visual Studio 2008 (SP1) with .Net 3.5 SP1 installed.  This is on a Windows 2003 R2 VPC with SharePoint 2007 (MOSS Enterprise) installed on the local machine for development.  A Collaboration Portal is installed on a web site with host headers (portal) assigned to port 80.

When I create a new workflow project, the wizard asks for a path to the SharePoint site.  I type in my url (http://portal in my case), and the project wizard fails, saying “SharePoint server not installed. Please run Microsoft Office SharePoint Server 2007 setup.“  

VS2008WF-SharePointNotInstalled

I’m logged in as the farm administrator.  I thought it might be a permissions issue (my farm admin doesn’t have full rights on the domain), so I went back and gave it full Domain Admin rights in case that was the problem.  Still failing!!

What the hell?

Resolution:

It turns out that the wizard does some funny business behind the scenes, calling the database directly.  When I give my development account (farm admin) account full rights (dbo) to the SharePoint content database for my portal site, bingo!  Works like a champ. 

After only an hour or two spinning my wheels.  Sigh….


  del.icio.us it! digg it! reddit! technorati! yahoo!

Categories: .Net · C# · MOSS 2007 · SharePoint · Visual Studio · Workflow

SharePoint – WSPBuilder Workflow Failed On Start

April 7, 2009 · 2 Comments

Building a SharePoint 2007 workflow using WSPBuilder and Visual Studio 2008.  Love, love, love the WSPBuilder tool, but the workflow templates could use some work.  Ran into this one today…

Problem

I was receiving “Failed on Start (retrying)” errors.  SharePoint logs showed “The workflow failed validation” exceptions.  This usually means a problem with the .rules files associated with a Declarative Rule Condition.  

I changed my While activities to use code conditions instead, and the problem went away.  But I really wanted to find the source of the issue.  After much trial and error and fruitless searches on the web, I finally found it.  Turns out, it was a missing import target declaration in the .csproj file created by WSPBuilder when I created a workflow project using the “WSPBuilder Workflow with Workflow” project template.

Resolution

To fix the problem, opened up the project file and added the missing import target line (in green), below. Evidently, this line tells studio to include the .rules in the assembly.

     <Import Project=”$(MSBuildBinPath)\Microsoft.CSharp.targets” />
     <Import Project=”$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.5\Workflow.Targets” />

Reopened the project, recompile, build wsp, redeploy.  Bingo!  Now my workflow works with Declarative Rule Conditions, as it should!

Credits

Thanks to Greg G’s post here that pointed me in the right direction.


: del.icio.us it! digg it! reddit! technorati! yahoo!

Categories: SharePoint · Visual Studio · WSPBuilder · Workflow

SharePoint – Size of Web Site or Folder (Easy Way)

April 4, 2009 · Leave a Comment

Ok, this is painfully easy.  Setup a Network Place in Windows Explorer, browse to the web site or folder in question, right-click -> Properties. 

Duh!!  Sometimes the solution is literally staring you in the face!  Thanks to Kelly Ballard for pointing this one out.

: del.icio.us it! digg it! reddit! technorati! yahoo!

Categories: SharePoint

SharePoint 2007 API – How To Change Layout and Publish Page

April 4, 2009 · 2 Comments

The hardest part about this (by far) is figuring out how to publish the page after you’ve made your changes.   Every time I need to do it, I have to dig up some old code.

Thought I’d blog it this time, to make it easier on myself next time around.

using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;
...

using (SPSite site = new SPSite("http://portal"))
{
    SPWeb web = site.RootWeb;

    // Check to ensure the web has publishing turned on
    if (!PublishingWeb.IsPublishingWeb(web))
    {
        throw new ApplicationException("Web does not have publishing enabled");
    }

    // Get a reference to the publishing web and publishing site    
    PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);
    PublishingSite pubSite = new PublishingSite(web.Site);

    // Get page layout from the page layouts collection    
    PageLayoutCollection siteLayouts = pubSite.GetPageLayouts(false);
    PageLayout myLayout = siteLayouts["/_catalogs/masterpage/MyLayout.aspx"];

    // Get a reference to a publishing page
    PublishingPageCollection pages = pubWeb.GetPublishingPages();
    PublishingPage page = pages["pages/default.aspx"];

    // Check out the list item as needed
    bool forceCheckout = page.ListItem.ParentList.ForceCheckout;
    if (forceCheckout)
    {
        // Is the page checked out?
        if (page.ListItem.File.CheckedOutBy != null)
        {
            // Throw an exception if the page is checked out
            string pageCheckedOut = string.Format("Page {0} is checked out by {1}", page.Url, page.ListItem.File.CheckedOutBy);
            throw new SPException(pageCheckedOut);
        }

        // Check out the page
        page.CheckOut();
    }

    // Change the page layout
    page.Layout= myLayout;

    // Update the page and check in changes
    page.Update();

    // Publish the page
    // This handles the page checkin and publishing the draft
    ApprovePublishingPage(page, "Modified page layout");

}

/// <summary>
/// Approves changes to a publishing page
/// </summary>
/// <param name="page">PublishingPage with changes to be published</param>
/// <param name="comment">Comment associated with the change</param>
public void ApprovePublishingPage(PublishingPage page, string comment)
{
    // Check in the page if required
    SPFile pageFile = page.ListItem.File;
    if (pageFile.Level == SPFileLevel.Checkout)
    {
        pageFile.CheckIn(comment, SPCheckinType.MajorCheckIn);
    }

    // Skip these steps if the parent list doesn't support moderation
    if (page.ListItem.ParentList.EnableModeration)
    {
        // If page is in "pending" status, approve it
        SPModerationInformation modInfo = page.ListItem.ModerationInformation;
        if (modInfo.Status == SPModerationStatusType.Pending)
        {
            pageFile.Approve(comment);
        }

        // If page is in draft status, publish it
        if (modInfo.Status == SPModerationStatusType.Draft)
        {
            pageFile.Publish(comment);
        }
    }
}

Enjoy!

  del.icio.us it! digg it! reddit! technorati! yahoo!

Categories: C# · MOSS 2007 · SharePoint