I am trying to deploy an event receivers project with a deployment target of WebApplication as part of my web parts package (also has a target of WebApplication) through Visual Studio and encountering the following error during the "Activate Features" step:
Error occurred in deployment step 'Activate Features': Operation is not valid due to the current state of the object.
The event receivers project is successfully deployed to the Sharepoint site but has not been activated as indicated in the error message. I can go to the Sharepoint site settings and manually activate the feature with no problems. If I change the deployment target of my event receivers project to the GAC then it deploys and activates correctly however we would prefer to use WebApplication deployment.
To test if it was some configuration issue with my event receivers, I removed my project and created a new one using the steps below:
- Add new Event Receiver project to solution (I selected "deploy as sandboxed solution")
- In the wizard, select "List Item Events", "Custom List" from the drop downs and "Item was added" and "Item being updated" from the list of check boxes
- Open project properties and change deployment target to WebApplication
- Add event receivers feature to web parts package
- Trying to deploy web parts package gives the error above in Visual Studio
Does anyone know where I'm going wrong?