Luke, don't use the '-force' (when reinstalling features)

Just a quick post to document a problem that I was having.

I was refreshing my memory on Event receivers and was following this tutorial: http://www.wrox.com/WileyCDA/Section/id-306329.html

The only difference between my code and the example was that I put in a comment (<!--like this-->) between the <Receivers> opening tag and the <Receiver> opening tag just to document something....well, SP doesn't like this at all and I got this error:

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.

So I took out the comment and reran the install and activate commands (from the command line) and everything worked fine...or so it said (I got the operation completed successfully), message.

However when trying to test the sample (after activating), I created a new announcements list and got an error. I checked the logs and lo and behold, there was my the error again:

'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.'

After plenty of fruitless searching for answers I decided to just deactivate the feature, fully uninstall the feature, then reinstall and activate. After that, everything worked like a charm.

Even though I had the -force option in the installfeature command, it still didn't work, so my advice, to avoid future headaches, is to fully uninstall any features when modifying them.

Comments

Popular posts from this blog

Programmatically Update Page Layouts

Microsoft Virtualilzation Headaches

ERROR: Failed to create feature receiver...