13/08/2009

SPJobDefinition Quirks For Developers

I wanted to write a quick heads up on a couple quirks relating to the SPJobDefinition and wiring up Timer Jobs (may be relevant for deployments where the Timer Jobs are modified). We are building our solutions on Windows 2003 Server with MOSS 2007.

To debug SPJobDefinitions attach VS debugger to OWSTIMER.exe process after following install instructions below.

OWSTIMER is caching the SPJobDefinition somewhere and is tricking Visual Studio into thinking we are actually debugging the most recent compiled version when we are debugging the last loaded version.

To fix this, kill the OWSTIMER process in process explorer (or restart the Windows Sharepoint Services Timer by typing the following at the command prompt: net stop sptimerv3 & net start sptimerv3) and then refresh the portal you are performing development on (this will force a restart of OWSTIMER.EXE and clear the cache).

Between tests ensure you completely remove the SharePoint feature (deactivate + uninstall) from Sharepoint (see below). Then kill the OWSTIMER process, iisreset, rebuild the solution and reinstall / activate the solution again (see below).

Here are a couple batch files convenient for removing / installing the jobs (where ProvisioningVX is the name of the feature you are trying to install):

Uninstall Batch File

@ECHO OFF

set SPAdminTool=%CommonProgramFiles%\Microsoft Shared\web server extensions\12\BIN\stsadm.exe
set TargetUrl=http://servername/sites/name

echo "Deactivating Feature"
"%SPAdminTool%" -o deactivatefeature -name ProvisioningVX -url %TargetUrl% -force

echo "Uninstalling Feature"
"%SPAdminTool%" -o uninstallfeature -name ProvisioningVX -force

iisreset

PAUSE

Installing and activating the feature

@ECHO OFF

set SPAdminTool=%CommonProgramFiles%\Microsoft Shared\web server extensions\12\BIN\stsadm.exe
set TargetUrl=http://servername/sites/name

echo "installing feature"
"%SPAdminTool%" -o installfeature -name ProvisioningVX -force

echo "activating feature"
"%SPAdminTool%" -o activatefeature -name ProvisioningVX -url %TargetUrl% -force

iisreset

PAUSE

12/08/2009

How To: Debug SPJobDefinition in Visual Studio

The solution is remarkably simple.

Click Debug -> Attach To Process

Note: At this point, ensure the checkbox "Select processes from all users" is selected.

Select OWSTIMER.EXE from the list.

Setup a breakpoint on the Execute override method.

Be patient and wait for the timed job to execute.

06/08/2009

My First Zune Badge: A Lesson in mediocrity

I finally got my first Zune badge today and with it, a lesson in mediocrity. Microsoft may want to rethink their strategy as to how these badges are issued as I now feel that I listen to a bunch of kindof sortof artists..

The Bronze Artist Power Listener award! Wooo Hooo. Are you kidding me? Thanks for this bronze mediocre accomplishment. What if it was a Platinum Artist Power Listener award? Does that mean I've listened to the most commercial music possible - that I am a power listener of platinum artists? What about, Gold. What about Silver.

Either way, I'm still happy that Microsoft has finally allowed me to create a Zune account. Thanks for the good work.

Over and Out