2

I have some data for my SP feature that is using the hierarchical object store to persist the data. I would like to read this data using the Client Object Model in an application that will be running on the users desktop machine. I can't seem to find a class that would allow me to do that. Is this possible? If so, how would I access it? Below is sample code of my persisted object class. I create this object using the static method on the class in an Administrative Console page. I want to be able to read (in this example) the value of the _myFavoriteMeat property from a client application (my application is straight C# 3.5 Winforms application).

[System.Runtime.InteropServices.GuidAttribute("AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA")]
public class MyCustomSettings : SPPersistedObject
{
    [Persisted]
    string _myFavoriteMeat;

    public MyCustomSettings() : base() {}

    public MyCustomerSettings(SPPersistedObject parent)
        : base("MySettingsName", parent)
    {
    }

    public static MyCustomSettings GetSettings()
    {
         MyCustomSettings settings = SPFarm.Local.GetChild<MyCustomSettings>("MySettingsName");
         if (settings == null)
         {
              settings = new MyCustomSettings(SPFarm.Local);
         }

         return settings;
    }

    public string MyFavoriteMeat
    {
         get
         {
             return _myFavoriteMeat;
         }
         set
         {
             _myFavoriteMeat = value;
         }
    }
}

1 Answer 1

2

I could be wrong, but I think you can only access objects at Site Collection level and lower (so not SPFarm level), and as SPPersistedObjects are written to the config database (not the content database) this rules out objects above Site Collection level being accessable.

This is documented in Stefan Stanev's blog post about getting SharePoint Manager 2010 to work with the Client Object Model: http://stefan-stanev-sharepoint-blog.blogspot.com/2010/05/sharepoint-2010-explorer-using-client.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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