Using Feature XML Files to Store Timer Job Configuration Settings

While working on a Timer Job project, I needed a flexible way to store one-time configuration settings. I was using a SharePoint Feature and FeatureReceiver to install and activate the Timer Job, so I decided to use the Feature.XML file as a repository for the initial configuration settings Job.

I used the Properties node of the feature.xml file to store the settings:










Then, during the FeatureActivated event, I passed those values into the Properties bag on the Timer Job class:























Then, in the Timer Job’s Execute method, grabbed those settings and used them:







I didn’t have a need to make run-time changes to the configuration settings, so this worked out really well. To change the defaults and apply new settings, the process was as simple as:

  • Deactivate the feature (uninstalls the Timer Job)
  • Change the feature.xml file
  • Re-activate the feature
3 comments on “Using Feature XML Files to Store Timer Job Configuration Settings
  1. Good idea – but I have a problem:

    Just deactivate/reactive the TimerJob over the Feature does not reload the new content from the feature.xml on the filesystem. I have to make a “iisreset” to provoke a reload of the filesystem feature.xml settings.

    Have I done something wrong?

  2. Hey Adam,
    Superb article. I was struggling a bit to find a better way of providing configuration values that can be read at the time of Feature Activation. Your article solved this in minutes.
    Thanks again.
    -Yogi

  3. Pingback: Rescheduling and running MOSS Timer Job « DotNetRaj

Comments are closed.