When debugging your custom SharePoint 2007 Timer Jobs you don’t necessarily need to attach to the OWSTimer process. All the blogs and information I have found out there on the interwebs suggest two options
- Attach your Timer Job code to the OWSTimer process and then wait for the job to execute
- Create a Console Application with the below code and run it whilst your Timer Job project is attached -
using (SPSite site = new SPSite("yoursharepointsiteurl"))
using (SPWeb web = site.OpenWeb())
foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
if (job.Title == "Your Job Name")
However I have had trouble getting the second option to work. For me when I let my Console Application run, the job doesn’t seem to execute and the breakpoints in my attached code don’t get hit.
Actually the EASIEST way is to place a breakpoint on the job.Execute line and then step in to the Execute method, this will actually step in to your Timer Job code and hit your breakpoints. However in order for it to step in to the code correctly you will need to have your Timer Job project open in a separate Visual Studio window/instance.
Hope this helps!