Windows SharePoint Services 3.0 provides a class library related to featue events, allowing you to capture and install the corresponding feature on the server farm, add it to a new virtual server, or uninstall it.
Some of the events arePostEvent, that is, triggered only after the action has been submitted or the feature definition has been created in the feature set.
It is impossible to cancel an installation or uninstallation operation through the feature event.
Feature event class
Microsoft. Sharepoint. spfeaturereceiverThe basic abstract class can be overwritten to capture the activation, shutdown, installation, or uninstallation operations of feature. Namespace:Microsoft. SharePoint
Microsoft. Sharepoint. spfeaturereceiverpropertiesClass provides access to event properties, such as the created feature instance, the definition of feature, or the parent object of feature (for example,Microsoft. Sharepoint. spwebObject ). Namespace:Microsoft. SharePoint
Events provided by feature
Feature provisioning callouts allows you to write specificCodeTo respond to various feature events throughout the lifecycle.SpfeaturereceiverClass provides the following methods to handle events:
Featureinstalled
Featureuninstalling
Featureactivated
Featuredeactivating
By creating an inheritedSpfeaturereceiverAnd implement these methods to provide corresponding event processing for feature.
You always pass the pointer to the parent object (such as a parent spweb), so you can customize it as needed.
DLL components that contain feature Receivers must be placed in GAC. In the feature. xml file, you can useReceiverassemblyAndReceiverclassProperty registers the receiver at the top layer of the feature element. For example:
< Feature ID = "5e88ae4e-2ecb-4cc5-b9ec-9019250f5bc8"
Title = "Knowledge base infrastructure"
Scope = "Site"
Receiverassembly = "Ms. samples. Sharepoint. Knowledgebase, version = 1.0.0.0, culture = neutral, publickeytoken = d24e3c1752ded9ed"
Receiverclass = "Ms. samples. Sharepoint. KnowledgeBase. knowledgebaseinstaller"
Xmlns = "Http://schemas.microsoft.com/sharepoint" >
Any exception thrown during the activation process will be transmitted to the user, and the feature will not be marked as activated.
Code is often used to handle situations where a user tries to force an activated feature to be activated. For example, if your feature creates a list during the call, make sure that the activation operation will not go wrong if the list already exists.