1
Vote

Error: Operation is not valid due to the current state of the object.

description

Hi,
 
I was getting Operation is not valid due to the current state of the object when I stepped through the constructor creating a new Item. I fixed that by running with elevated privileges. then I bumped into the SPweb object not working because the list is in the root of the site and the SPweb constructor can't take a blank string. I Hardcoded it with "/" and that got past that. Then I get a new Item, set all its data fields then when I run update I get... "Operation is not valid due to the current state of the object."
I suspect it might be that I called Update() and I don't have an SPContext since the code is running on a non sharepoint site. Any other clues?
 
Thanks
 
Anthony

comments

asumner wrote Sep 15, 2008 at 4:46 PM

This isn't the List Access Layer problem, I've isolated that with test code... off on a learning curve :)

asumner wrote Sep 15, 2008 at 5:42 PM

It's a known problem it seems. The HttpContext does not have current web against the key "HttpHandlerSPWeb", and of course it won't because the code is running in a non sharepoint web site. It therefore will not have this handler installed?

jnoirfal wrote Sep 18, 2008 at 8:37 AM

Hello Anthony,

First, thank you for all your suggestions and issues.
I will modify the generator with all of them (duplicated names and elevated privileges) and will publish a new release for october.

Kind regards,
Jérôme

wrote Jan 21, 2013 at 5:47 PM