[SharePoint 2010] Debugging a Custom SharePoint Timer Job
When creating custom SharePoint timer jobs in Visual Studio 2010 you cannot debug the timer job like you would a web part or application page by simply hitting F5 or the Debug button. Instead, you have to deploy the project to your local SharePoint instance and then attach the debugger to the SharePoint Timer Process. MSDN has instructions on how to do this, but I have posted them here as well.
In your Execute function of the Timer Job, set a breakpoint.
Deploy your solution to the local SharePoint instance (right-click the project name in the Solution Explorer and select Deploy). If you have previously deployed this project, you may need to reset the SharePoint Timer Service in order for it to refresh the code.
From the Debug menu, select Attach To Process.
Select OWSTIMER.EXE and Attach. If you do not see OWSTIMER.EXE in the list, be sure that the “Show processes from all users” and “Show processes in all sessions” checkboxes are checked. If you still do not see it listed, be sure that the SharePoint Timer Service is running. If you receive a security warning about the process running as a different user, select Attach.
In Central Administration, start your Timer Job. It should now execute and pause at the breakpoint you created.
That’s it. I hope you find this as useful as I have.
2 Comments
Leave a comment
Follow John Chapman
SharePoint StackExchange
- http://t.co/d2YzH8q1 - #sharepoint - [SharePoint 2010] Specifying Which Server a Custom Timer Job Will Run On
- Always have your stuff when you need it with @Dropbox. 2GB account is free! http://t.co/kczsnniq
- http://t.co/iLWV2Kwp - #sharepoint - [SharePoint 2010] Web Analytics: Monitors the health of the Report Consolidator component
Recent Posts
- [SharePoint 2010] Specifying Which Server a Custom Timer Job Will Run On
- [SharePoint 2010] Web Analytics: Monitors the health of the Report Consolidator component
- [SharePoint 2010 / SQL Server 2008] Query the SharePoint Object Model from a .NET SQL Server CLR Function
- [SharePoint 2010] Debugging a Custom SharePoint Timer Job
- [SharePoint 2010] Set Access Request Email for All SharePoint Sites




It doesn’t work for me, even when I use the same example exactly.
After setting the breakpoint and deploying the project, you may need to restart the SharePoint Timer Service as it caches the DLLs for timer jobs. Thanks.