2

I'm trying to activate a Web-scoped feature using the Client Object Model in SharePoint 2010. The code works when activating a feature in SharePoint 2013, but when run against SharePoint 2010, I get the following error:

Error Message: featdefScope
Stack Trace:

System.ArgumentException: 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...

using (ClientContext clientContext = new ClientContext("http://site"))
{
    clientContext.Credentials = new System.Net.NetworkCredential(userName, password);

    Web web = clientContext.Web;
    clientContext.ExecuteQuery();

    Guid featureGuid = new Guid(featureId);
    web.Features.Add(featureGuid, true, FeatureDefinitionScope.None);

    clientContext.ExecuteQuery();
}

I can activate the feature through the UI and PowerShell on the same server running the code, and again, this code works when run against SharePoint 2013.

How can Web-scoped feature be activated using the Client Object Model for SharePoint 2010?

Your Answer

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

Browse other questions tagged or ask your own question.