Saturday, October 9, 2010

How to debug SharePoint 2010 "SPJobDefinition" code

The class inherited from SPJobDefinition is running (hosted) by windows service "SharePoint 2010 Timer" ("OWSTIMER.EXE"). So we need to do some extra work before the debugging.

Add these code into "Pre-deployment Command Line" section:


@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\14\bin\stsadm"


net stop SPAdminV4


%STSADM% -o deactivatefeature -name EF_SimpleReminder -url http://hvsp2010 -force
%STSADM% -o execadmsvcjobs


net start SPAdminV4


net stop SPTimerV4
net start SPTimerV4




Re-create job in "Feature activated" event:

Now, we can deploy the job through Visual Studio 2010, then attach to the process "OWSTIMER.EXE" and begin to test it.

No comments:

Post a Comment