Sue Hernandez's Blog

March 31, 2011

Error occurred in deployment step ‘Activate Features’: Operation is not valid due to the current state of the object

Filed under: SharePoint 2010, Visual Studio 2010 — Susan Hernandez @ 4:29 pm

SharePoint 2010 and Visual Studio 2010.

I added an Event Receiver to a new Visual Studio 2010 project.  Very simple.  It was of type EmailReceived but I don’t think that matters in this case.  I went to deploy the project and got the following error message:

“Error occurred in deployment step ‘Activate Features’: Operation is not valid due to the current state of the object”

Apparently reading up on many people’s posts this can be many things.  Turns out mine was because I did something so normal:  I renamed the namespace and the class name of the class.  Well apparently when I did that, I got out of sync with the automatically generated Elements.xml – which I couldnt’ find at first.

So pop open your “EventReceiver1″ file in solution explorer – expand the files underneath it by pressing the + sign.  Double-click the Elements.xml file.  You will see something like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <Receivers ListTemplateId="101">
      <Receiver>
         <Name>
EventReceiver1EmailReceived</Name>
         <Type>EmailReceived</Type>
         <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
         <Class>YourProjectNameHere.EventReceiver1.EventReceiver1</Class>
         <SequenceNumber>10000</SequenceNumber>
      </Receiver>
   </Receivers>
</Elements>

My problem was the <Class> element.  I had renamed my namespace to MyNamespace and my project to MyProjectName.  So my class should have been MyNamespace.MyProjectName.  That was it.

Easy

13 Comments »

  1. Great, tsx! Save my time a lot!

    Comment by AMG — September 20, 2011 @ 11:15 am

  2. Thank You!!!

    Comment by sayitfst — October 10, 2011 @ 8:18 pm

  3. Thanks for this post. Saved some time!

    Comment by Jon — October 25, 2011 @ 3:25 pm

  4. Thanks! It’s help me a lot.

    Comment by chungtran — November 3, 2011 @ 4:39 am

  5. Thanks !

    Comment by suchon — November 27, 2011 @ 4:49 am

  6. Great post — thank you!!

    Comment by Lori — January 25, 2012 @ 3:10 pm

  7. This was my problem too, thanks!

    Comment by Alejandro — February 6, 2012 @ 1:06 pm

  8. Great one. Thanks. Saved lots of time

    Comment by Sachira — March 11, 2012 @ 9:02 am

  9. Too many thanks. It solved my problem

    Comment by Mohamed Ramadan — March 25, 2012 @ 10:04 am

  10. Thank you for the post. It solved my problem too.

    Comment by Rashmi — April 2, 2012 @ 12:05 pm

  11. Thanks a lot :)

    Comment by Abdul-Rahman — May 9, 2012 @ 4:35 am

  12. that was it for me, too! I’ve seen this before in my work, but, it had been a while and I forgot. Thanks for the reminder!!!

    Comment by bkwdesign — May 11, 2012 @ 3:54 pm

  13. Reblogged this on Truongconglong's Blog.

    Comment by truongconglong — May 12, 2012 @ 9:25 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.