ERROR: Failed to create feature receiver...
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
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
Comments
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
What file/code do i need to change to overcome this error message?
Regards,
Dan
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.
Thanks,
Ryan
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.
1) Uninstall assembly from the GAC (gacutil /u )
2) DEPLOY your project.
but I got the same problem but mine is different...
CArefully lookat "FeatureReceiver" name both feature.xml and your class name !!
FeatureReciever vs FetureReceiver
see receiver spelleing...i mispelled in feature.xml
Hope it helps someone.....