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

  1. Add new Event Receiver project to solution (I selected "deploy as sandboxed solution")
  2. 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
  3. Open project properties and change deployment target to WebApplication
  4. Add event receivers feature to web parts package
  5. Trying to deploy web parts package gives the error above in Visual Studio

Does anyone know where I'm going wrong?

share|improve this question
add comment

3 Answers 3

Basically, this error can occur if your feature remains activated and you have uninstalled the solution directly (there are chances that u have deployed solution on two sites and while retracting, it is missed to be deactivated from the one of the site, in such cases, this thing happens).

The solution is, deactivate the feature from all the sites, then retract your solution and redeploy it from VS.

share|improve this answer
add comment

I had the same issue.

I had to switch to "No Activation" in VS and then activate feature manually once deployed via VS.

share|improve this answer
add comment

I have ran into a similar situation.. you can try following things 1)check the element.xml file.. if you have changed the name space of the project ..you would have to make the relevant changes in the element.xml file <Class>NameSpace.ProjectName</Class>

2)If you are targeting this event recivier to a specific list , then make sure that you have the url correct in

<Receivers ListUrl="/Lists/ListName">

3)Reset the iis server and close the visual studio and reopen it and check if it is working. Hope this helps!

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.