Deploying features with activation dependencies (SharePoint development) - by JensOtto

Status : 

  Duplicate<br /><br />
		This item appears to be a duplicate of another existing Connect or internal item.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 644470 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/16/2011 2:26:08 AM
Access Restriction Public


Developing SharePoint 2010 solutions in Visual Studio 2010.

There is a problem in Visual Studio when deploying a solution with activationdependencies. Consider the following scenario.

There are two features A and B, both are both site or web scoped. A has an activation dependency on B and B is hidden. When deploying the solution Visual Studio tries to activate both features. First it activates A. This automatically activates B since it's hidden. Then when Visual Studio tries to activate B it failes with the error: "Error occurred in deployment step 'Activate Features': Feature 'B' (ID: <feature id>) is already activated at scope '<site url>'."

This can be solved by installing Mavention Activate Selected Features and selecting only feature A for activation. Visual Studio should however be able to correctly activate features without relying on 3rd party extensions.

The next problem arises when trying to retract or do a second deploy. Visual Studio will again try to deactivate both features. First A is deactivated and because of the activation dependency and that feature B is hidden this will simultaneously deactivate B. When Visual Studio then tries to deactivate B it fails with the error: "Error occurred in deployment step 'Retract Solution': Feature '<feature id>' is not activated at this scope."

Possible solutions that I can think of: 
B is deactivated before A. (I have not found a reliable way of controlling the order of deactivation)
B is never deactivated directly by Visual Studio. (I have not found an equivalent of Mavention Activate Selected Features for feature deactivation)
Visual Studio ignores the error caused when the feature is not activated.

Please note that it seems that the order of activation/deactivation sometimes is reversed. If this happens then simply switch the role of feature A and B (set A as hidden, B as visible, and reverse the activationdependency).
Sign in to post a comment.
Posted by Pieter_Veenstra on 11/22/2011 at 5:57 AM
I find the following workaround easier:
1. Disable the autoactivation of features in the Project properties -> SharePoint
2. Start the feature manually in SharePoint.

This workaround only really helps when you don't have too many features to activate, but I found that many of my solutions have a single feature with feature dependencies (=all other features in the solution) activating all other features.
Posted by Microsoft on 3/15/2011 at 8:29 PM
Hi Jens,

The fix is not in VS2010 SP1, but in next version of VS2010. If it blocks you and you want to fix it as soon as possible in VS2010 SP1, please contact our support via the Visual Studio Help and Support page on MSDN.

Posted by JensOtto on 3/8/2011 at 11:31 PM

Is this not fixed in VS 2010 SP1? I have installed and testet it, and still have the same problem.

Jens Otto
Posted by Microsoft on 2/17/2011 at 10:55 PM
Hi there,

Thanks for reporting the issue! We've noticed this bug and fixed it in next release of Visual Studio. If you have further comments, please feel free to let me know.

Xiaoying Guo
Program Manager, Visual Studio Business Applications Tooling
Posted by Microsoft on 2/16/2011 at 2:58 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(