1

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 WebParts A uses
  • A stapling feature (C): staples A to a site definition

Is it possible to have a Feature Dependency from A onto B that will cause B to be automatically activated? I've tried it in various combinations using the standard Feature Dependency 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?

4
  • 1
    This will explain to you why it's not working:msdn.microsoft.com/en-us/library/aa543162.aspx
    – Michael M
    Commented Aug 18, 2011 at 4:16
  • @Michael: Gosh, that is a good answer...
    – Stu Pegg
    Commented Aug 18, 2011 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
    Commented Aug 19, 2011 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".
    – Stu Pegg
    Commented Aug 19, 2011 at 7:09

1 Answer 1

1

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...

3
  • +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.
    – Stu Pegg
    Commented Aug 17, 2011 at 17:16
  • Stuart, see Michaels comment on why it's not working. Commented Aug 18, 2011 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. :)
    – Stu Pegg
    Commented Aug 18, 2011 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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