Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have three features in a solution:

  • A Web-scoped feature (A): has a FeatureActivated call to set up a site
  • A Site-scoped feature (B): contains web parts A uses
  • A stapling feature (C): staples A to a site definition

Is it possible to have a Feature Dependancy from A onto B that will cause B to be automatically activated? I've tried it in various combinations using the standard Feature Dependancy section on feature A, but the activation always fails.

If this isn't possible using the standard method, is there an alternative method I can use?

share|improve this question
1  
This will explain to you why it's not working:msdn.microsoft.com/en-us/library/aa543162.aspx –  Michael M Aug 18 '11 at 4:16
    
@Michael: Gosh, that is a good answer... –  Stuart Pegg Aug 18 '11 at 7:23
    
:) Well I didn't feel it really helped you solve your question rather merely confirmed the reason for the behaviour you described. –  Michael M Aug 19 '11 at 1:02
    
@Michael: Well to be fair I rolled two questions into one; the first part was "will this work?", to which the answer was "no". –  Stuart Pegg Aug 19 '11 at 7:09
add comment

1 Answer 1

up vote 1 down vote accepted

Since you're already having a feature receiver for (A), you could easily in your FeatureActivated method of (A) in code activate feature (B) on the site collection level. Just a few lines of code...

share|improve this answer
    
+1 It's a fair point, and I have briefly looked at SPSite.Features.Add (if that's what you're referring to). I was hoping to use the standard method, or at least understand why it doesn't work. –  Stuart Pegg Aug 17 '11 at 17:16
    
Stuart, see Michaels comment on why it's not working. –  Wictor Wilen MCA MCM MVP Aug 18 '11 at 6:33
    
Fair enough. Since your answer helps me work around the issue, I'll mark this as accepted. Obviously I'll still upvote Michael's answer if he takes the massive hint. :) –  Stuart Pegg Aug 18 '11 at 7:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.