I am trying to find a good resource/example of using the SPPersistedObject class (or objects derived from it). I am running into a lot of snafu's, snags, and general "I don't know why this won't work" issues with trying to use the hierarchial object store to store my feature settings in. I have found lots of very simple boiler plate examples, but I am trying to do something a lot more complex and have not found any examples like it. I found a question at StackOverflow that is closely related to (and seeing the same errors) what I am doing, but even that does not offer any further insight nor does it look like the problem has actually been solved. Here is a rundown (from a high level) of what I am trying to do. I have not seen any documentation that describes how to do this. Maybe I shouldn't be doing this at all. I based this off the MSDN documentation about SPPersistedObject that says that the class contains code to:
serialize all its members that are base types, other persisted objects, and collections of persisted objects
I have already run into the fact that the term
collections as far as I can tell only means lists and dictionaries since HashSets put the system in a bad place. This is what led me to derive several classes from SPPersistedObject in the hope that I could then string them all together. And now, the rundown.
- I have a base
BaseFeatureSettingsclass derived from SPPersistedObject that is persisting a couple of strings.
- A class derived from
SpecificFeatureSettings, this class contains to persisted
List<Guid>objects as well as a persisted
- A base class
BaseSettingsclass derived from SPPersistedObject that persists a Guid, a string, a
List<string>a bool and a custom flag enum.
- A class derived from
SpecificSettingswhich persists and int and string.
- A collection class
PersistedSpecificSettingsCollectionthat derives from SPPersistedObject and implements
IDictionary<Guid, SpecificSettings>which contains a persisted
Basically in my code I am accessing the
SpecificFeatureSetting and wanting to update it, and push that back into the store. I am able to access the specific feature, and update the strings that are part of the base class of SpecificFeature, but when I try to update the collection that it is also persisting, the number of items in the collection goes up, but they are always null. I also get another error:
An object in the SharePoint administrative framework, depends on other objects which do not exist. Ensure that all of the objects dependencies are created and retry this operation.
Here is a question I posted earlier on StackOverflow, it contains a code snippet of my class hierarchy (although I have made some minor changes, it should give you a good high level picture of what I have described above).