Share via


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 https://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="https://schemas.microsoft.com/sharepoint/">
  <!-- Document library -->
  <!--           
    <Receivers ListTemplateId="101" >
     <Receiver>
      <Name>My eventhandler</Name>
      <Class>MyEventHandler.DocumentLibraryHandler</Class>
      <Assembly>MyEventHandler, Version=1.0.0.0, 
                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=1.0.0.0, 
                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!

J

Comments

  • Anonymous
    July 26, 2007
    The comment has been removed

  • Anonymous
    September 10, 2007
    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!

  • Anonymous
    October 16, 2007
    Wow, I would have never found this without your post... Thanks!

  • Anonymous
    November 06, 2007
    I would have gone on for hours before trying this.   Why do I think they are laughing back in Redmond. Thanks for posting this.

  • Anonymous
    December 16, 2007
    Thanks a lot. You've saved my time and nerves. Thank for your post.

  • Anonymous
    March 06, 2008
    I just ran into this today. It blows my mind that this isn't more documented! Does no one comment their work anymore??

  • Anonymous
    April 14, 2008
    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!

  • Anonymous
    July 20, 2008
    The comment has been removed

  • Anonymous
    January 11, 2010
    It's 2010 and this post is still helping people - me.  Thx.

  • Anonymous
    April 04, 2011
    You saved my day. I would have debugged for hours and wasted time. Thank you very much.

  • Anonymous
    March 13, 2013
    Thanks for this blog! Worked like a charm. I debugged for hours and wasted time too.