Home > SPTimerJobs > Sharepoint Timer Jobs and Microsoft Enterprise Library

Sharepoint Timer Jobs and Microsoft Enterprise Library

september 18th, 2009

I had a problem at one of my projects with a Sharepoint Timer Job. It was running fine for a while but after two months it started throwing errors. The code that creates sharepoint sitecollections is relying on the Enterprise library for things such as exception handling.

Since the unit test and web application ran fine I had not checked that the timer job processed the exceptions correctly. Turned out that exceptions did not get logged because the timer jobs run on their own context rather than in context of a webapplication. Hence the web.config settings for the Enterprise library could not be loaded. The unit tests have their own app.config but where would you place such settings for a SPTimer job?

Turns out it is pretty easy! Since the SPTimer job runs in context of the owstimer.exe in the bin directory of the Sharepoint 12 Folder you can add your own config settings file. If you already had a unit test in VS.NET with a correct app.config, then just copy that one to the Sharepoint 12/BIN folder, rename it to owstimer.exe.config and hey presto all your Enterprise Library settings will now load correctly. Remember to copy it to all Sharepoint servers where the timer job is running.

Thanks to Henk Drent and http://www.thesug.org/Blogs/mossmania/archive/2007/12/19/Using_a_Config_File_for_Windows_SharePoint_Services_Timer_Jobs.aspx.aspx for helping out on this one!

roelhans SPTimerJobs , ,

  1. No comments yet.
  1. No trackbacks yet.