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 created two features and I want both use same receever class so I created a class MyFeatureReceiver (some where in project SP/MyRecievers/) which implements SPFeatureReceiver and has a attribute [Guid("1F6B71C6-5AC2-4D02-87D5-7C3729CE6E3B")].

I have modified the properties of my two features as following:

Scope="Web" 
ReceiverClass="$SharePoint.Type.1F6B71C6-5AC2-4D02-87D5-7C3729CE6E3B.FullName$"
ReceiverAssembly="$SharePoint.Project.AssemblyFullName$"

I use PowerShell to deploy .wsp file which I have checked in CA and it is ok. but when I create site collection and its root web, it generates "Failed to create receiver object from assembly ..."

I have another project which has used same principle and works fine, in that project when I go to the Features and choose their manifest the "$SharePoint.Type.1F6B71C6-5AC2-4D02-87D5-7C3729CE6E3B.FullName$" has been replaced with the namespace + the class name but in my project it has not been replaced and I think it is the problem. thanks for your help.

share|improve this question
add comment

1 Answer 1

If your class is:

  • in the same project
  • inherits from SPFeatureReceiver
  • is public
  • has the right [Guid(xxx)] attribute

then it should work, but I would consider it a bad practice. A better solution woulc be to have two destinct feature receivers calling common functions, then if at some point you need to differentiate (could be in regards to FeatureUpgrading), then it'll be easier.

share|improve this answer
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.