Tuesday, February 3, 2009

Debugging Timer Job

I have already written some articles about writing and managing the Timer Job.One of my student asked me how to debug the timer job.

Its preety simple. Follow the following step to debug the Timer Job.
1. Open the Visual Studio and the Timer Job code base
2. Set the break point in the code
3. Attach the debugger to OWSTimer.exe
4. Wait for the next cycle of the timer job.

Make sure that you dont set Timer Job interval more than 5 min for development purpose, otherwise you need to wait for longer.

You can also execute the Timer Job forcefully by writing a small console application.
using STSADM command line


stsadm -o execadmsvcjobs
Other Consideration:
When you change the code base for the Timer Job, deploy the new binary in GAC and RESET the OWSTimer.exe service.

Yes you are right I said OWSTimer and not IIS Reset , because timer job run inside the OWStimer process only and till you restart it, it will always run it from previously cached copy.