var feature = spSite.Features.SingleOrDefault(sf => sf.Definition.DisplayName.ToLower().Equals(strFeatureName));//Error block
if (feature != null)//if feature is activated
{
spSite.Features.Remove(feature.DefinitionId);//deactivate feature
spSite.Features.Add(feature.DefinitionId);//activate feature
}
I am using this code to check for activated features using a windows forms app. It is working fine in local but showing object reference error in DEV machine. I suspect the first line might be causing the error.
Can anyone figure out what would be causing the error and a workaround for this?