I was working on a STSDev project which deployed a feature with a feature receiver. I had the feature working without the FeatureReceiver but as soon as I added the FeatureReceiver related attributes to my <Feature> element I got the following error:
Failed to create feature receiver object from assembly "Org.Project.Solution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c632353d405b3209", type "Org.Project.Solution.MyFeature.FeatureReceiver" for feature 6a9b2358-ea4e-486d-a4e4-4f813c52ce88: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
After much digging around I discovered that STSDEV's Solution config file refers to a namespace as well as the dll. My FeatureReceiver's namespace was not prefixed with the right namespace
So just be sure that your project conforms to the following:
SolutionName (default name of outputted assembly): Org.Project.Solution (Org.Project.Solution.dll)
FeatureName: MyFeature
FeatureRecieverName: FeatureReceiver (in FeatureReceiver.cs)
Feature Namespace: Org.Project.Solution.MyFeature
SolutionConfig.xml's SafeControl's Namespace Attrib: Org.Project.Solution
Feature.xml's <Feature> ReceiverClass Attribute: Org.Project.Solution.MyFeature.FeatureReceiver
Feature.xml's <Feature> ReceiverAssembly Attribute: Org.Project.Solution
Friday, May 23, 2008
ERROR: Failed to create feature receiver...
Labels:
errors,
FeatureReceivers,
features,
STSDEV
Subscribe to:
Post Comments (Atom)
8 comments:
Thank you Paul. That just saved me many hours.
OH man this was a HUGE help!!!!! Thanks a bunch WOOT!!!
I am getting the exact same error when I try to activate the feature on MySite.
What code, or what file, do I need to change, to prevent this error from appearing?
I just don't fully understand how you got it working.
Thanks,
Dan
I get the exact same error message, when I try to activate the feature on MySite.
What file/code do i need to change to overcome this error message?
Regards,
Dan
Dan, does it only happen on mysite (i.e. it works on regular sites)?
This post describes this problem happening when working with STSDEV, if you are not using STSDEV there could be a few problems. Make sure your feature receiver's namespace is the same namespace specified in the feature.xml file and in the manifest.xml file.
Paul, you mention that the receiver's namespace needs to be the same namespace specified in the feature.xml file and in the manifest.xml file. I'm a little confused as to what you're saying here. What namespace in the feature.xml and manifest.xml are you referring to?
Thanks,
Ryan
Paul, you mention that the receiver's namespace needs to be the same namespace specified in the feature.xml file and in the manifest.xml file. I'm a little confused as to what you're saying here. What namespace in the feature.xml and manifest.xml are you referring to?
Ryan,
When you want to add a feature reciever to a feature you need to have a 'ReceiverAssembly' attribute on your 'feature' element in your feature.xml file. In addiiton, when you are using STSDEV a manifest.xml file is made for you automatically. If you open this file you'll see that there is a reference to your assembly in there as well. If you change your project name, namespace (or class name) of your receiver class, or add a feature receiver in later you might mess this up and get the error listed above.
By checking that all these are in agreement you might be able to solve your problem if you get the 'Failed to create feature receiver' error.
This post is the gift that keeps on giving. Thanks for the help, this information was exactly what I needed.
Post a Comment