Recently I posted an article that discussed the SPWebConfigModification. I meant to add some information about problems with XML Namespaces and SPWebConfigModification.
One of the first problems my team encountered with SPWebConfigModification was failures when working with configuration settings that overrode the default xml namespace (xmlns).
The problem arose when we tried to apply the webconfig modifications needed to for the Enterprise Library. Below is a sample entry from the configuration settings needed for Enterprise Library. Notice how the default xmlns is being overridden.
<enterpriselibrary.configurationSettings applicationName="NewsApplication" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration" />
That one statement invalidates the XPath expressions in the SPWebConfigModification Name and Path properties. This means that SPWebConfigModification cannot successfully find the entry when it scans the web.config file. So every time the web.config file is modified by SPWebConfigModification the entry gets duplicated (which causes the web.config file to be invalid).
A little research into the way .Net Framework handles XML namespaces turned up the XmlNameSpaceManager class. This class is used to define namespaces at runtime.
Unfortunately SPWebConfigModification does not expose this class when defining the XPath expressions. If it did it would be possible to work with XML namespaces.
By the way, the team was able to work around the enterprise library configuration problem by moving the EntLib configuration settings into separate files.

0 comments:
Post a Comment