To find the modification that is failing, I added a breakpoint and whilst debugging opened the following statement in QuickWatch in Visual Studio:
SPFarm.Local.Services.GetValue<SPWebservice>()
Then I navigated through the following properties in the Quick Watch window:
WebApplications/base/base/Non-Public members/BackingList
This offers access to all the web applications on the farm. For each web application under that node, open the WebConfigModifications node and check each one for the path that is reported to be failing. Then you can delete that faulty WebCofigModification using the following code:
foreach (SPWebApplication thisApp in SPFarm.Local.Services.GetValue<SPWebService>().WebApplications)
{
for (int i = thisApp.WebConfigModifications.Count; i > 0; i--)
{
SPWebConfigModification mod = thisApp.WebConfigModifications[i - 1];
if (mod.Path.ToLower().Contains("[TEXT IN BAD PATH]"))
thisApp.WebConfigModifications.Remove(mod);
}
thisApp.Update();
}
By deleting the faulty modification from the collection, the ApplyWebConfigModifications() call will now run to completion without raising an exception.
1 comment:
Thanks for this post. You set me on the right track for solving a config problem I am having. I came across this feature that I thought you would find useful. It enables you to edit the config list through Central Administration.
http://blog.thekid.me.uk/archive/2007/03/24/web-config-modification-manager-for-sharepoint.aspx
Post a Comment