This article will teach you how to extend a feature receiver to add more events to the default, somewhat limited event model.
Whats the problem with the current Feature Receiver Event Model?
The Feature Receiver event model provided by Microsoft is too limited, it lacks some very important events, the 4 events it does support are:
So what’s missing?
Most noticably whats missing is a FeatureOnError event, since this would also be too generic, ideally we need support for FeatureOnActivatingError, and anymore you can think of. This is because a feature runs through the CAML feature definition while activating, and out of the box, there is no way to catch an error during the activation.
Another important event thats missing is FeatureOnBeforeActivate – this is because you might want to do some prechecks before running through the feature element manifests, so the event FeatureActivated fires after the element manifests have been loaded.
There is one very easy way to add these events, and whats nice about this method is if you know how to code a feature you will have no problems understanding the code.
The theory is (a) to change your current features visibibility to hidden, then (b) create another feature which will be responsible for the activation of your first feature.
Code listed below:
<code to follow>