I am trying to activate the "SharePoint Server Publishing" feature of a sub-site. The process is that a user clicks a button and the following events take place:
- sub-site is provisioned
- custom pages added to "Site Pages" library
- activate "Publishing" feature
- other items done
Here is the code I am using to attempt to activate the "Publishing" feature:
Guid DefaultSiteSettingsFeatureGuid = new Guid("22a9ef51-737b-4ff2-9346-694633fe4416");
SPFeature feature = ChildWeb.Features[DefaultSiteSettingsFeatureGuid];
if (feature == null)
{
ChildWeb.Features.Add(DefaultSiteSettingsFeatureGuid);
}When the code runs it breaks at step #3 and the feature is not activated. Why?
Thanks for the assistance.