there is a farm feature and there is a web-scoped feature. web feature does stuff on multiple sites. If ever i want to get rid of the feature on all sites, I have a farm feature that has on deactivate following code, while on-activate is empty(no logic): Is there something wrong with my code?? I get "value does not fall within the expected range" error...
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
System.Diagnostics.Debugger.Break();
SPSite tmpRoot = new SPSite("http://omac-spsdev01");
SPSiteCollection tmpRootColl = tmpRoot.WebApplication.Sites;
foreach (SPSite site in tmpRootColl)
{
foreach (SPWeb web in site.AllWebs)
{
string FeatureID = "5f71dfd4-20dd-432f-ae60-60e31f5e972b";
//Get feature Guid
Guid myfeatureid = new Guid(FeatureID);
//remove feature
//SPFeatureCollection features = web.Features;
//SPFeature myfeature = features[FeatureID];
if (web.Features[myfeatureid] != null) //Make sure Feature is installed!
{
web.Features.Remove(myfeatureid);//deactivate feature
}
web.Dispose();
}
site.Dispose();
}
}