1

I have created a class that parses an xml file and then adds the appropriate modifications to the web.config in my SharePoint 2010 web applications. When a feature is activated the proper mods are added to the web.config and when it is deactivated or uninstalled the mods are retracted.

In my xml I have about 9 nodes that are marked EnsureSection so I can be sure that some of the elements I need for example and are in the web.config. I do not retract these nodes when a feature is deactivated since I don't want to interfere with someone else using those nodes in the application.

Today I was poking around with PowerShell and I noticed that when I get the web application contentservice and look at the WebConfigModifications collection in memory; the mods that are for ensuring sections have been replicated in the collection. They have been replicated the number of times that I have activated the feature from the Central Admin.

I have code that wraps the adding of the mods so if they are already present in the collection I do not re-add them. I do not understand why the items that I have marked as EnsureSection are being replicated in the collection. Does anyone know why those mods would be getting multiplied like that?

2
  • 1
    Not that this comment is the least bit constructive, but this sounds like one of the problems people generally have with SPWebConfigModifications - it's duplicating of entries even when you tell it not to do so.
    – James Love
    Mar 20, 2013 at 19:47
  • Indeed. I could not figure out how to stop this so we have switched over to a pure powershell solution for our entries. We are in a multi-tenant farm so we can't just wipe the collection each time which is what I was doing before.
    – Maxmanzero
    Jul 17, 2013 at 16:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.