Hi,
I´m developing a feature to edit the web.config file. I have followed a few tutorials and finally I write this code
public class WebConfigRecieverEventReceiver : SPFeatureReceiver { private const string cWebConfigModificationOwner = "owner"; SPWebConfigModification spWebConfigModification = new SPWebConfigModification() { // The owner of the web.config modification, useful for removing a // group of modifications Owner = cWebConfigModificationOwner, // Make sure that the name is a unique XPath selector for the element // we are adding. This name is used for removing the element Name = "bindings", //Name = "mySection[@name=\"Prueba\"]", // We are going to add a new XML node to web.config Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, // The XPath to the location of the parent node in web.config Path = "/configuration/system.serviceModel", // Sequence is important if there are multiple equal nodes that // can't be identified with an XPath expression Sequence = 0, // The XML to insert as child node, make sure that used names match the Name selector Value = "<bindings/>" }; public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebService newService = SPWebService.ContentService; newService.WebConfigModifications.Add(spWebConfigModification); newService.Update(); newService.ApplyWebConfigModifications(); }
Debugging my code I have an exception when I try to aply the web config modifications. This is the exception:
An exception of type 'System.Xml.XPath.XPathException' occurred in System.Xml.dll but was not handled in user code
Additional information: '' is an invalid expression.
Anybody can help me? I don´t know where the fail is. I think it´s the web.config root but I´ve copied the same as other users have copied any the don´t have problems.
Thanks in advance.