1

Ive created a very simple custom site provisoning provider as a test and im having some problems and cant figure out why. Basically at this moment all the site provisioner does is enable publishing at the site collection level and the site level. However it errors out stating that "The SharePoint Server Publishing Infrastructure feature must be activated at the site collection level before the Publishing feature can be activated.". Ive commented out the code that enables the feature at the site level and verified that the publishing feature is actually enabled when i create a new site collection from my template.

Any ideas as im stumped

props.Web.ApplyWebTemplate("PROJECTSITE#0"); SPSecurity.RunWithElevatedPrivileges(() => { using (SPSite siteCollection = new SPSite(props.Web.Site.ID)) { using (SPWeb web = siteCollection.OpenWeb(props.Web.ID)){ siteCollection.Features.Add(new Guid("f6924d36-2fa8-4f0b-b16d-06b7250180fa")); web.Features.Add(new Guid("22a9ef51-737b-4ff2-9346-694633fe4416")); } } }); 
1
  • Did you try activating these features by adding them to Onet.xml of your web template? Commented May 9, 2014 at 9:35

1 Answer 1

1

The state of the features is probably being cached between your two Features.Add lines. I would first move the line that adds the site collection feature so that it occurs before opening the SPWeb. Secondly, if you are still seeing issues with it being cached, open the site collection a second time to do the SPWeb feature. For instance:

SPSecurity.RunWithElevatedPrivileges(() => { using (SPSite siteCollection = new SPSite(props.Web.Site.ID)) { siteCollection.Features.Add(new Guid("f6924d36-2fa8-4f0b-b16d-06b7250180fa")); } using (SPSite siteCollection = new SPSite(props.Web.Site.ID)) { using (SPWeb web = siteCollection.OpenWeb(props.Web.ID)){ web.Features.Add(new Guid("22a9ef51-737b-4ff2-9346-694633fe4416")); } } }); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.