Tuesday, February 25, 2014

SPFeatureReceiver.FeatureUninstalling ...or is it solution retraction?

copyright from: blogs.sharepointdam.com

I just realized there isn't that much documentation available on SharePoint's FeatureUninstalling method, so I thought I should share my experience with it.
 
FeatureUninstalling will only be called when the feature is uninstalled on the last web application. Therefore it is somewhat like a "Solution is being Retracted" event.
 
The properties.Feature property will be null, so you need to access your feature elements via the SPFarm object (SPContext doesn't work here either, as has been documented a lot on the web).
 
A solution retraction does NOT necessarily call a FeatureDeactivating for all deployed feature instances, so you might want to iterate through your WebApplications and Sites to clean up and deactivate any remaining features.

No comments: