I'm trying to create an OOTB team site in a site collection where publishing is enabled.
Not sure what is happening, I've looked into everything from permissions, to TaxonomyHiddenList issues, problems with fields and output cache, but no luck.
Surely it has to do with custom fields/code, but considering what is supposed to be provisioned (Site Assets, Site Pages), I don't understand what could be wrong, and if I indeed have an issue with one of the fields.
System.ArgumentException: Value does not fall within the expected range., StackTrace:
at Microsoft.SharePoint.SPField.set_SchemaXml(String value)
at Microsoft.SharePoint.SPList.fixFieldShema(SPField fld, String strXml)
at Microsoft.SharePoint.SPList.FixFieldsFromColumnTemplate()
at Microsoft.SharePoint.SPWeb.SyncNewLists(Boolean bCreateFromSTP)
at Microsoft.SharePoint.SPWeb.ApplyWebTemplate(SPWebTemplate webTemplate, Page page, SPFeatureDependencyErrorBehavior featureDependencyErrorBehavior, ICollection`1& featureDependencyErrors)
at Microsoft.SharePoint.ApplicationPages.TemplatePickerUtil.ApplyWebTemplateAndRedirect(SPWeb Web, String strWebTemplate, Nullable`1 bSharedNav, Boolean bOnTopNav, Boolean bOnQuickLaunch, Page page, Boolean bDeleteOnError, SPFeatureDependencyErrorBehavior featureDependencyErrorBehavior, ICollection`1& featureDependencyErrors)
at Microsoft.SharePoint.ApplicationPages.NewSubwebPage.BtnCreateSubweb_Click(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
Output from PowerShell attempt (error 0x80070057)
Similar questions:
Findings:
- team site creation works fine in other site collections
- can export an existing team site as template and create a site from that template
- blank sites, blogs, etc all work fine
- looking at the reflected code, I should be getting a clearer exception, not sure why it is not coming up in the logs
Code:
// Microsoft.SharePoint.SPList
private void fixFieldShema(SPField fld, string strXml)
{
bool flag = false;
System.Guid id = fld.Id;
SPWeb parentWeb = this.ParentWeb;
if (!string.IsNullOrEmpty(strXml) && fld.FromBaseType)
{
string fieldAttributeValue = fld.GetFieldAttributeValue("Type");
string b = null;
string schemaXml = fld.SchemaXml;
int num = strXml.IndexOf(">", System.StringComparison.OrdinalIgnoreCase);
int startIndex = schemaXml.IndexOf(">", System.StringComparison.OrdinalIgnoreCase);
if (num >= 0)
{
string text = strXml.Substring(0, num);
int num2 = text.IndexOf(" Type=", System.StringComparison.OrdinalIgnoreCase);
if (num2 > 0)
{
num2++;
text = text.Substring(num2);
num2 = text.IndexOf("\"", System.StringComparison.OrdinalIgnoreCase);
if (num2 > 0)
{
int num3 = text.IndexOf("\"", num2 + 1, System.StringComparison.OrdinalIgnoreCase);
if (num3 > num2)
{
b = text.Substring(num2 + 1, num3 - num2 - 1);
}
}
}
flag = (fieldAttributeValue != b);
if (fld.Type == SPFieldType.Computed)
{
strXml = strXml.Substring(0, num) + schemaXml.Substring(startIndex);
}
}
}
if (fld.Type == SPFieldType.Lookup && !flag)
{
SPFieldLookup sPFieldLookup = fld as SPFieldLookup;
if (sPFieldLookup != null)
{
strXml = this.EnsureLookupFieldSchemaXmlHasList(sPFieldLookup.LookupList, strXml);
}
}
if (!fld.FromBaseType || !flag)
{
if (SPLocalizationCollection.HasLocalizations(strXml))
{
using (new SPSecurity.SuppressAccessDeniedRedirectInScope())
{
try
{
SPLocalizationCollection fieldLocalizations = this.ParentWeb.FieldLocalizations;
if (fieldLocalizations != null)
{
fieldLocalizations.Localize(strXml, out strXml);
}
}
catch (System.UnauthorizedAccessException)
{
}
}
}
try
{
if (fld is SPFieldDateTime && parentWeb.RegionalSettings.CalendarType != 1)
{
SPField sPField = parentWeb.AvailableFields[id] as SPFieldDateTime;
if (sPField != null && !string.IsNullOrEmpty(sPField.DefaultValue) && sPField.DefaultValue.EndsWith("Z", System.StringComparison.OrdinalIgnoreCase))
{
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
using (System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(new System.IO.StringReader(strXml)))
{
xmlTextReader.DtdProcessing = DtdProcessing.Prohibit;
xmlDocument.Load(xmlTextReader);
}
System.Xml.XmlElement xmlElement = xmlDocument.DocumentElement.SelectSingleNode("Default") as System.Xml.XmlElement;
if (xmlElement != null)
{
int calendarType;
if (!SPGlobal.GetNamedIntItem(xmlDocument.DocumentElement, "CalType", out calendarType) || calendarType == 0)
{
calendarType = (int)parentWeb.RegionalSettings.CalendarType;
}
string innerText = xmlElement.InnerText;
xmlElement.InnerText = SPUtility.GregorianISOToIntlISODate(parentWeb, innerText, calendarType);
fld.SchemaXml = xmlDocument.DocumentElement.OuterXml;
}
else
{
fld.SchemaXml = strXml;
}
}
else
{
fld.SchemaXml = strXml;
}
}
else
{
fld.SchemaXml = strXml;
}
}
catch (SPException ex)
{
ULS.SendTraceTag(2142736u, ULSCat.msoulscat_WSS_General, ULSTraceLevel.High, "Error Update Field with id '{0}' for list {1} with schema {2}, Exception: {3}", new object[]
{
id.ToString("B"),
this.InternalName,
strXml,
ex
});
}
}
}