Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Use the Client Object Model to activate a feature

$
0
0

I'm trying to activate a web and/or site feture using the Client Object Model (Microsoft.SharePoint.Client). I've tried many variations but always get this error message...

Error Message: Feature with Id '3bae86a2-776d-499d-9db8-fa4cdc7884f8' is not installed in this farm, and cannot be added to this scope.
Stack Trace:

Microsoft.SharePoint.Client.ServerException: at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery() at ...

Here is the C# code...

// Get the client context
using (ClientContext clientContext = new ClientContext("http://site"))
{
    // Load the features
    Site clientSite = clientContext.Site;
    FeatureCollection clientSiteFeatures = new Guid("3BAE86A2-776D-499d-9DB8-FA4CDC7884F8"); // Document Set Site Scoped Feature
    clientContext.Load(clientSiteFeatures);
    clientContext.ExecuteQuery();

    // Activate the feature
    clientSiteFeatures.Add(FeatureId, false, FeatureDefinitionScope.Site);
    //clientSiteFeatures.Remove(FeatureId, false);
    clientContext.ExecuteQuery();
}

I can activate the feature through the UI and PowerShell on the same server running the code. In addition, I can use the same code to deactivate the feature by commenting out the add method and uncommenting the remove method. How can a site or web feature be activated using the Client Object Model? 

The following thread involves the same question but no correct answer was given yet the question was marked as answered. As a result I thought I would repost the question.

http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/d063e579-8cbe-4522-8c1e-eec83329a12b


Jeremy Luerkens

Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>