Unable to debug a custom timer job in sharepoint

11,796

Solution 1

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.

Solution 2

Try loading debug symbols manually and see what it says:

To display the Modules window in break mode or in run mod

On the Debug menu, choose Windows, and then click Modules.

By default, the Modules window sorts modules by load order. However, you can choose to sort by any column.

In the Modules window, you can see which modules have debugging symbols loaded. This information appears in the Symbol Status column. If the status says Skipped loading Cannot find or open the PDB file, or Loading disabled by include/exclude setting, you can direct the debugger to download symbols from the Microsoft public symbol servers or to load symbols from a symbol directory on your computer. For more information, see How to: Use a Symbol Server and How to: Specify Symbol Locations and Loading Behavior.

To load symbols manually

In the Modules window, right-click a module for which symbols have not loaded.

Point to Load Symbols From and then click Microsoft Symbol Servers or Symbol Path.

copied from MSDN

You can also try to delete Visual Studio cache just to be sure (from command prompt):

del /Q %LOCALAPPDATA%\Microsoft\WebsiteCache
del /Q %LOCALAPPDATA%\Temp\VWDWebCache
del /Q %LOCALAPPDATA%\Microsoft\Team Foundation\1.0\Cache
Share:
11,796
Thomas Mathew
Author by

Thomas Mathew

Updated on June 05, 2022

Comments

  • Thomas Mathew
    Thomas Mathew almost 2 years

    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?