Monday, July 29, 2013

Not valid state of the object

Error occurred in deployment step 'Activate Features':Operation is not valid due current state of the object.

If you receive this error while developing the "Sandbox" solution in SharePoint 2010 using Visual studio 2010.

The reason will be:
You might have trying to change the Sharepoint's solution type "sandbox to Farm" by setting the attribute in VSS 2010.

or SPUserWorkerProcess not been started on your WFE or error occurred in deployment steps.

To resolve this,

Go to your Solution gallery in the Site collection,if you found the solution deactivate it.

Or
Go back to your Visual studio solution explorer and empty all your features (select all features hit the delete button,it will goes to your right hand side of the feature window.)
Now change the solution type to "Farm or Sandbox". Last but not least, Check your event receiver class and its namespace are correctly referred in "Element.xml".

Or,

trying to call the SPSite/SPWeb class in the feature using SPContext. or trying to access the object thats all ready closed by using "using operator" in feature event receiver.