I'm trying to update web.config in SharePoint when the feature is activated. I have created Event receiver. The code inside receiver is:
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();
}
When I'm deploying feature I have received the following error: "Error occurred in deployment step 'Activate Features': Expression must evaluate to a node-set."
What is wrong with this?