This issue is related to this post.
I get an error message when the publishing feature is activated on sites of certain types. This means that I also get an error message when I create certain sites that are dependent on the Publishing Feature (and thereby activate the feature on site creation) e.g. Enterprise Wiki.
In my ULS-log, I see that the publishing feature is being activated. When it's almost done (after the event LRO - Starting background thread, job=Updating available web templates, this=50934842), it goes for another publishing provisioning taks, but it returns the following exception:
InitializePublishingWebDefaults failed. Microsoft.SharePoint.SPException: The object specified does not belong to a list.
at Microsoft.SharePoint.SPWeb.GetItem(String strUrl, Boolean bFile, Boolean cacheRowsetAndId, Boolean bDatesInUtc, String[] fields)
at Microsoft.SharePoint.SPFile.get_Item()
at Microsoft.SharePoint.Publishing.MasterUrlProperty.SetDirectValue(String value, SPWeb web)
at Microsoft.SharePoint.Publishing.InheritableProperty`1.SetInherit(Boolean inherit, Boolean forceAllSubWebInherit, String successUrl, String failureUrl, Boolean& updateRequired)
at Microsoft.SharePoint.Publishing.InheritableProperty`1.SetInherit(Boolean inherit, Boolean forceAllSubWebInherit, Boolean& updateRequired)
at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetMasterPageProperties(PublishingWeb area, Boolean& updateRequired)
at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetLayoutRelatedProperties(PublishingWeb area, Boolean& updateRequired)
at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.InitializePublishingWebDefaults()
and after that the following error message is shown / logged:
Event log message was: 'Failed to initialize some site properties for Web
at Url: 'http://local/entwiki''. Exception was: 'Microsoft.SharePoint.SPException: The object specified does not belong to a list.
at Microsoft.SharePoint.SPWeb.GetItem(String strUrl, Boolean bFile, Boolean cacheRowsetAndId, Boolean bDatesInUtc, String[] fields)
at Microsoft.SharePoint.SPFile.get_Item()
at Microsoft.SharePoint.Publishing.MasterUrlProperty.SetDirectValue(String value, SPWeb web)
at Microsoft.SharePoint.Publishing.InheritableProperty`1.SetInherit(Boolean inherit, Boolean forceAllSubWebInherit, String successUrl, String failureUrl, Boolean& updateRequired)
at Microsoft.SharePoint.Publishing.InheritableProperty`1.SetInherit(Boolean inherit, Boolean forceAllSubWebInherit, Boolean& updateRequired)
at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetMasterPageProperties(PublishingWeb area, Boolean& updateRequired)
at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetLayoutRelatedProperties(PublishingWeb area, Boolean& updateRequired)
at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.InitializePublishingWebDefaults()'
The strange thing is that this only happens when I use my custom master. I have a feature which loops through all the webs in a sc and applies this method:
public static void ApplyBrandingMaster(SPWeb web)
{
Uri masterUri = new Uri(web.Site.RootWeb.Url + "/_catalogs/masterpage/custom_main.master");
web.MasterUrl = masterUri.AbsolutePath;
web.CustomMasterUrl = masterUri.AbsolutePath;
web.Update();
}
It seems that if the master is NOT applied, there is no error. What could be wrong? I don't see how the master and the publishing feature are related this way.