visual-studiodebuggingsharepointsharepoint-2007timer-jobs

Unable to debug a custom timer job in sharepoint


I tried the following steps in order to debug a particular custom timer ( installed and activated):

  1. Copied the both .dll and .pdb files in the GAC.
  2. Restarted the timer services.
  3. Attached both w3wp and OWSTimer.exe processes.

But the debugging is still not taking place. The debugger placed is empty circle which displays this message:

The breakpoint will not currently be hit. No symbols have been loaded for this document.

The OWSTimer is shown in a diff username. Does It needs to be run from my account?

Why debugging is not working?


Solution

  • Debugging Timer Jobs can be hard... The steps you took sound about right, but you can also do some more:

    1. Timer Jobs run in OWSTimer.exe - you only need to attach to that one
    2. Restart the timer service. For good measure throw in a restart, deploy, restart, iisreset ;-)
    3. Did you do a DEBUG Build or RELEASE build?
    4. Make sure you actually RUN your timer job (as in trigger it)

    If your breakpoints are still not hit, do something ugly: use Debugger.Launch() or Debugger.Break() in your code or an assertion which will always fails: System.Diagnostics.Trace.Assert(false);

    And then there is MSDN for the rescue.