PANVEGA’s Blog

DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

SharePoint Feature Activation Dependences

Posted by PANVEGA on September 7, 2009

A XML element that you can add to our FEATURE.XML is called, “ActivationDependencies”. When WSS activates a feature that defines activation dependencies, it automatically activates any dependent feature that has already been activated.

Here is an example of an activationdependence for the publishing feature.

<ActivationDependencies>

<ActivationDependency FeatureId=”F6924D36-2FA8-4f0b-B16D-06B7250180FA”/>
</ActivationDependencies>

How do we know that this is the Publishing Feature? The FeatureID refers to the GUID of the FEATURE.XML for that feature. (So now it should make sense why each feature needs a unique GUID).

So here is the amended FEATURE.XML.

<Feature Id=”01c34560-6561-11dc-8314-0800200c9a66″

Title=”Nice to know”
Description=”This is a feature that adds a new sexy CSS”
Version=”1.0.0.0″
Scope=”Site”
xmlns=”http://schemas.microsoft.com/sharepoint/”>
<ActivationDependencies>
<ActivationDependency FeatureId=”F6924D36-2FA8-4f0b-B16D-06B7250180FA”/>
</ActivationDependencies>
<ElementManifests>
<ElementManifest Location=”ProvisionedFiles.xml”/>
</ElementManifests>
</Feature>

Some important informatin you have to when dealing with activationdependence:

  • If a feature is dependent on another feature at the same scope, and that feature is not on, it will be turned on.
  • Feature activation dependencies are not supported across scopes if the dependent feature is not visible (i.e., you can’t have a web scoped feature dependent on a site scoped feature that the admin can’t see in the site feature UI.)
  • If the dependent feature is not activated, activation of the dependee feature will fail.
  • You can’t have a dependency from a ‘higher’ scope to a ‘lesser’ scope
  • Hidden features are frequently used as dependent features, but cannot themselves have dependencies.

The SDK page ActivationDependencies Element (Feature) states that only hidden features can be activated/deactivated automatically and that hidden features can not have activation dependencies. This means that you must have a visible feature to activate and that you can only activate features from the visible feature.  You can not have a hierarchy of hidden features dependant on each other and have them all automatically activate in the correct order.

More information:

http://msdn.microsoft.com/en-us/library/aa543162.aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: