14

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?

6 Answers 6

7

I 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!

3

I had the same issue.

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

1

I had the same issue.

I have removed "Feature" files from Feature folder in the solution, and deployed via VS. Again redeployed "with" feature files via VS. It worked.

0
1

This guy's blog post suggests killing vssphost.

This wasn't enough on its own, however it was the missing link in my overall process.

I wrote this automated script to reset the entire environment in one command.

The gist is basically to stop all the services, kill the vssphost, flush the config cache, and then restart the services. It's a lot of steps to do manually, and so this script helps automate that process.

0

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.

0

I got this error when trying to add a constructor. Removing the constructor fixed the deploy (but left me without a common entry point).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.