Export (0) Print
Expand All

How to: Debug a Timer Job

Overview

When you create a timer job for Microsoft® SharePoint® 2010, you cannot directly press F5 to debug your code. Instead, you must attach the debugger to the SharePoint 2010 Timer process (Owstimer.exe). This how-to topic describes how to debug a timer job by attaching the Visual Studio debugger to the timer process.

Ff798310.note(en-us,PandP.10).gifNote:
This how-to topic uses the simple timer job described in How To: Create a Web Application-Scoped Timer Job as an example.

Steps

To debug a timer job in Visual Studio 2010

  1. On the Start menu, point to Administrative Tools, and then click Services.
  2. In the Services window, make sure the SharePoint 2010 Timer service is started.
  3. Open the Visual Studio 2010 project that contains your timer job.
    Ff798310.note(en-us,PandP.10).gifNote:
    Make sure that the code has not changed since you deployed the timer job; otherwise, the debugger will not match your source code to the deployed assembly.

  4. Set a breakpoint in the Execute method of your job definition class.

    Ff798310.3aebdfeb-2b19-41aa-a8e2-431acfdc1185(en-us,PandP.10).png

  5. On the Debug menu, click Attach to Process.
  6. In the Attach to Process dialog box, click OWSTIMER.EXE, and then click Attach.

    Ff798310.85cd2ff8-42a3-47c4-8940-5565d391b020(en-us,PandP.10).png

  7. If the Attach Security Warning dialog box is displayed, click Attach.
  8. In the SharePoint Central Administration Web site, click Monitoring, and then click Review job definitions.
  9. Click the name of your job, and then click Run Now on the Edit Timer Job page.
  10. Verify that the Visual Studio 2010 debugger stops execution on your breakpoint.

    Ff798310.9a4a3603-9483-48d3-a7df-49c81490d044(en-us,PandP.10).png



Show:
© 2014 Microsoft