I am creating a SharePoint function, and in my FeatureReceiver I am trying to add SPWebConfigModification . I followed the approach described in this blog post.
Here is a snippet from my function receiver:
public override void FeatureActivated(SPFeatureReceiverProperties properties) { var webApp = (SPWebApplication)properties.Feature.Parent; var debugMode = new SPWebConfigModification { Path = "configuration/system.web/customErrors", Name = "mode", Value = "Off", Sequence = 0, Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute, Owner = "MyWebConfigMods" }; webApp.WebConfigModifications.Add(debugMode);
Here is the stack trace from the error, as shown in the SharePoint ULS Viewer:
Feature receiver assembly 'MyCompany.SharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxx', class 'MyCompany.SharePoint.Features.WebConfig.WebConfigFeatureReceiver', method 'FeatureActivated' for feature '3a07b91c-0968-4f14-b2bc-ae0e3f109cf9' threw an exception: System.Xml.XPath.XPathException: '' is an invalid expression. at MS.Internal.Xml.XPath.XPathScanner..ctor(String xpathExpr) at MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(String xpathExpresion) at MS.Internal.Xml.XPath.QueryBuilder.Build(String query, Boolean allowVar, Boolean allowKey) at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver) at System.Xml.XPath.XPathNavigator.Select(String xpath) at System.Xml.XmlNode.SelectSingleNode(String xpath) at Microsoft.SharePoint.Administration.SPWebConfigFileChanges.ApplyModificationsWebConfigXmlDocument(XmlDocument xdWebConfig, String filepath) at Microsoft.SharePoint.Administration.SPWebApplication.ApplyWebConfigModifications() at Microsoft.SharePoint.Administration.SPWebService.ApplyWebConfigModifications() at MyCompany.SharePoint.WebConfigModificationFeatureReceiver.FeatureActivated(SPFeatureReceiverProperties properties) at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce)
Somewhere during the upgrade, an empty path references an XPath expression. This is not in my function. Any ideas?
source share