Tuesday, April 17, 2012

Nasty error when writing data to SharePoint List

I am working on a SharePoint console app that needs to import data from an XML file into a SharePoint list. All was going well, and then suddenly I get the following error:

Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))

It happened at the SaveChanges call, and for Googlers at:


No, I was not disposing the current SPContext (the most likely cause of this problem) since I was in a console app. So what else could it be? This post on stack overflow helped me figure it out.

One of the fields I have in the SharePoint list is a Yes/No field. SPMetal created a nullable bool form this, and so I figured I could safely ignore it if I chose to. Not the case. Once I started providing a value to that nullable bool, all was well again. The field definition for that Yes/No field does have a default value defined in CAML, but if this is the cause of the problem is not clear and I don't have time to test at the moment.

Moral of the story, if you are updating a list and see the error above, check that you are providing values to any bool fields. Likely the same story for choice fields and who knows what else.

1 comment:

Vardhaman Deshpande said...

I had the same issue and guess what! If you do not provide default values to any of the Yes/No columns, it works. Remember to remove default values from all your Yes/No Choice columns