SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Completley new to sp and trying to create a timer job that uses a value stored in a persisted object. I found some examples but for some reason when my job runs the persisted object is always null. My code is below

code to retrieve the object

 ContentDataBaseIncrementorJobSettings Settings = WebApplication.GetChild<ContentDataBaseIncrementorJobSettings>(ContentDataBaseIncrementorJobSettings.SettingsName);

 if (Settings == null) {

code in the feature activated event

        ContentDataBaseIncrementorJobSettings ContentDataBaseIncrementorJobSettings =

        //only create a new settings object if there isnt one.
        if (ContentDataBaseIncrementorJobSettings == null) {
            ContentDataBaseIncrementorJobSettings = new ContentDataBaseIncrementorJobSettings(WebApplication, Guid.NewGuid());
            ContentDataBaseIncrementorJobSettings.CurrentIncrement = 10;

my persisted object definition

   public class ContentDataBaseIncrementorJobSettings : SPPersistedObject {
            public static string SettingsName = "ContentDatabaseIncrementorTimerJobSettings";

            public ContentDataBaseIncrementorJobSettings() : base() { }
            public ContentDataBaseIncrementorJobSettings(SPPersistedObject parent, Guid id) : base(SettingsName, parent, id) { }

            public int CurrentIncrement;
share|improve this question

As per MSDN thread "To return an existing persisted object, use the GetObject method of the SPFarm class, or the GetChild method of the SPPersistedObject class". Try using WebApplication.SPFarm.GetObject()

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.