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.

  1. In your Execute function of the Timer Job, set a breakpoint.

  2. 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.

  3. From the Debug menu, select Attach To Process.

  4. 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.

  5. 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.

Source


Pin It on Pinterest

Share This
%d bloggers like this: