I'm trying to modify the web.config file when the feature is activated with the code below:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = (properties.Feature.Parent as SPSite).WebApplication;
SPWebConfigModification modification = new SPWebConfigModification("mode", "system.web/customErrors");
modification.Owner = "modifyAccountFeatureOwner";
modification.Sequence = 0;
modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute;
modification.Value = "Off";
webApp.WebConfigModifications.Add(modification);
webApp.Update();
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
}
But I'm receiving this error in the step Activate Features:
Error occurred in deployment step 'Activate Features': '' is an invalid expression.
Anyone know what is causing this error?
web.configs
can be a painful job. Is PowerShell an option instead of server-side code?