MOSS and EventHandler deployment with features + Cannot insert the value NULL into column…

I posted earlier about my nasty experiences with site column deployment. This time I was working with eventhandlers and had interesting error message that I thought I’d share to you. I had created a pretty simple eventhandler and it was working fine. But then I needed to make few modifications and needed to deploy my eventhandler again. And then I saw following error message:

stsadm -o activatefeature 
-filename MyWeirdEventHandler\feature.xml
-url http://server/MyWeirdSite Cannot insert the value NULL into column 'Name',
table 'WSS_Content_Portal.dbo.EventReceivers';
column does not allow nulls. INSERT fails. The statement has been terminated.

But this time I was smart enough to check changes in my EventHandler.xml file. And I noticed that I have commented Receivers as seen below:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="">
  <!-- Document library -->
    <Receivers ListTemplateId="101" >
      <Name>My eventhandler</Name>
      <Assembly>MyEventHandler, Version=, 
Culture=neutral, PublicKeyToken=c68c273ce9d7cee3</Assembly> <SequenceNumber>1000</SequenceNumber> <Type>ItemDeleting</Type> </Receiver> </Receivers> --> <!-- Forms library --> <Receivers ListTemplateId="115"> <Receiver> <Name>My eventhandler</Name> <Class>MyEventHandler.DocumentLibraryHandler</Class> <Assembly>MyEventHandler, Version=,
Culture=neutral, PublicKeyToken=c68c273ce9d7cee3</Assembly> <SequenceNumber>1000</SequenceNumber> <Type>ItemAdding</Type> </Receiver> </Receivers> </Elements>

So somehow commenting that first section caused the feature activation to fail. I don’t know why that happens but it’s still good to know the reason for that error message. I hope this helps someone who has that error message and doesn’t know what to do.

Anyways… happy hacking!


Comments (11)

  1. Mark Kamoski says:

    Thank you VERY much for this tip. As far as "why on God’s green earth SharePoint cannot handle a standard comment in an XML file", who the heck knows. It is making my ears bleed to hear this (yet more) bad news about SharePoint. Microsoft really, really, really should avoid trying to make their products "fancy" until AFTER then get the basic stuff working. I love SharePoint in many ways, but ug, come on guys and gals. Get the basic stuff done first. Thanks again. — Mark

  2. Rita Girman says:

    Thank you, thank you, thank you!  Drove myself batty trying to get my simple event feature to activate.  Removed all comments from Elements.xml and viola!…activation done.  Curses, Microsoft!

  3. Brinkie says:

    Wow, I would have never found this without your post… Thanks!

  4. John C says:

    I would have gone on for hours before trying this.   Why do I think they are laughing back in Redmond.

    Thanks for posting this.

  5. Serge Prokhorov says:

    Thanks a lot. You’ve saved my time and nerves. Thank for your post.

  6. Corey Dutson says:

    I just ran into this today. It blows my mind that this isn’t more documented! Does no one comment their work anymore??

  7. Lucy says:

    Thanks for this blog! I would never of thought that commented code would have caused my problems! My feature was working fine. My error occured when I wanted to create a new document library. I then got this error ‘Unknown Error’. I found the same error that you have in the logs file and then found this article. After removing my commeneted code my error has gone! Thanks again!

  8. Log0 says:

    Nasty enough, thanks for the help. It really helps.

  9. Andy says:

    It’s 2010 and this post is still helping people – me.  Thx.

  10. Jigger says:

    You saved my day. I would have debugged for hours and wasted time. Thank you very much.

  11. Vinit says:

    Thanks for this blog! Worked like a charm. I debugged for hours and wasted time too.

Skip to main content