Working with SharePoint 2010, I have a class that inherits SPPersistedObject with various settings:

[Serializable] class Settings : SPPersistedObject
    [Persisted] private string setting1; // getters and setters etc. exist for each field

These settings (properties) are supposed to be globally accessible from the application code. Every time the value of one or more of them changes, Update() method is called so that other parts of the code (i.e. other aspx pages) may read the correct, up-to-date value.

This works fine as long as I'm only accessing properties within the same application that updated them, e.g.: http://abc:5100/.../test.aspx updates Settings.Setting1, calls Update(); other :5100 pages will now see the new value in their code. However - and this is my problem - when I read Settings.Setting1 property from, say, http://abc:26233 /.../temp.aspx, the old value (pre-Update) is retrieved instead of the new one. This leads me to believe that the property is read from some kind of in-memory copy instead of from the updated store. The new value is retrieved only if I manually use 'iisreset /restart' beforehand, but that is not desirable.

I would greatly appreciate it if someone has any idea on how to update/read the properties so that the change is reflected across the entire farm, i.e. the value is read from a common permanent store.


Answer moved from question:

In case anyone ever encounters this one, the solution is to use the SPPersistedObject.Clone() method on your class, e.g. (not the actual code, but illustrates the point):

Settings s = (Settings)SettingsObj.Clone();
return s.Setting1; // returns updated value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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