Note that there are some explanatory texts on larger screens.

plurals
  1. POSharePoint 2010 - Receiving error attempting to use SPWebConfigModification
    text
    copied!<p>I'm creating a SharePoint feature and within my <code>FeatureReceiver</code> I'm attempting to add a <code>SPWebConfigModification</code>. I've been following the approach outlined in <a href="http://weblogs.asp.net/wesleybakker/archive/2009/01/21/web.config-modifications-with-a-sharepoint-feature.aspx" rel="nofollow noreferrer">this</a> blog post.</p> <p>Here is a snippet from my feature receiver:</p> <pre><code>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); // &lt;------ Error is thrown at this line webApp.WebService.ApplyWebConfigModifications(); webApp.Update(); } </code></pre> <p>Here is the stack trace from the error as seen in the SharePoint ULS viewer:</p> <pre><code>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) </code></pre> <p>Somewhere during the update an empty path is being referenced within an <code>XPath</code> expression. It's not in my feature. Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload