As Daniel Larson mentioned in a reply in the "SharePoint – Development and Programming"-forum the usage of the SPWebConfiguration-class is a bit tricky. When you have a look into the description of the SPWebConfigModification-class in the MSDN-Library, you will see, that the class has two constructors. I think it’s a good way to use this one:

public SPWebConfigModification ( string name, string xpath )

Here you can explicitly state a unique name for your modification. But remember Daniel Larson’s reply, that this unique name should be an xpath expression, so that you can remove a modification you have done.

Example:

When you have to add this node

<assemblies>
       <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>

to the configuration/system.web/compilation/assemblies node of the web.config, you should instantiate the SPWebConfigModification-class this way:

[…]
string strUniqueName = "add[@assembly=’System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′]";
string strNode = "configuration/system.web/compilation/assemblies";
SPWebConfigModification modification = new SPWebConfigModification(strUniqueName, strNode)
[…]

You should also read the postings from:
Mark Wagner
Daniel Larson
Ted Pattison

Advertisements