Manage configuration modifications problems

Nov 13, 2007 at 4:20 PM
Hey Scot Hillier
I have look at your "Manage Configuration Modifications", for getting som tips to modi. my web.config file when I run a feature
My code:
private void AddRemoveWebConfigModification(SPWebApplication WebApp, bool AddModification)
{
string modName = "add@Assembly='MyAss, Version=1.0.0.0, Culture=neutral, PublicKeyToken=snkKey'";
string modPath = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes";
string modValue = "<authorizedType Assembly='MyAss, Version=1.0.0.0, Culture=neutral, PublicKeyToken=snkKey' Namespace='MyAss' TypeName='*' Authorized='True' />";
string modOwner = "DISGIEftersynsFirmaWorkflow";
uint modSequence = 1;
SPWebConfigModification.SPWebConfigModificationType modType = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;

SPWebConfigModification modification = new SPWebConfigModification(modName, modPath);

modification.Owner = modOwner;
modification.Sequence = modSequence;
modification.Type = modType;
modification.Value = modValue;

if (AddModification)
WebApp.WebConfigModifications.Add(modification);
else
WebApp.WebConfigModifications.Remove(modification);
WebApp.Update();

SPFarm.Local.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
}

but when i try to remove my modification from my web.config nothing happens, why?
Nov 14, 2007 at 11:33 AM
This is because the Name must be a valid XPath expression that will return the Value. SharePoint uses the Name to locate the Value when it is removed.

Scot