Gorgo.Live.ToString()

Mariusz, Gorzoch tech Blog

How to get rid of SPPersistedObject

with one comment

Be aware… SharePoint API is a little bit tricky and here is a good example of that. If you are using “SPPersistedObject” class you should know that to remove this object from persisted store you can not just call “delete” method, but you need also call “Unprovision” and “Uncache”:

AP200JobSettings settings = this.WebAppSelector.CurrentItem.GetChild<AP200JobSettings>(Globals.SharePointAP200JobSettingsId);
//if there is no settings or we get command to clear settings (thru parameter) – then we set-up new empty settings object
if (settings!=null && (!String.IsNullOrEmpty(Request.QueryString["cls"])))
{
    settings.Delete();
    settings.Unprovision();
    settings.Uncache();
    settings = null;
}

if you won’t call the other two methods you will end-up with cryptic error as so:

An update conflict has occurred, and you must re-try this action. The object SPFarm-2b89-4f2e-a928-b52bb8774e3b is being updated by NT AUTHORITY\NETWORK SERVICE, in the w3wp process, on machine OVIDIUBECHES.  View the tracing log for more information about the conflict

Advertisements

Written by Mariusz Gorzoch

12 May 2010 at 11:16

Posted in SharePoint

One Response

Subscribe to comments with RSS.

  1. […] we can delete the SPPersistedObject object from the configuration database as shown here in the feature deactivation event receiver. […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: