c# - System.InvalidOperationException: Operation is not valid due to the current state of the object.? -


i developing asp.net mvc application sharepoint foundation 2010. asp.net application hosted on 1 machine , sharepoint foundation 2010 hosted on machine. have deployed 1 custom wcf service inside isapi folder of sharepoint environment. custom wcf service creates content databases programatically. asp.net application consumes custom wcf service. using approach because scenario similar link - http://blog.sharedove.com/adisjugo/index.php/2012/07/31/creating-site-collections-in-specific-content-database/. implemeting above scenario getting error - http://social.technet.microsoft.com/forums/en-us/sharepointdevelopmentprevious/thread/f10d009b-13c4-4942-86b4-2ab8c4f5994d. have solved error http://beyondweblogs.com/sharepoint-2010-sppersistedobject-access-denied/. getting error - system.invalidoperationexception: operation not valid due current state of object.

system.invalidoperationexception: operation not valid due current state of object.    @ microsoft.sharepoint.webcontrols.spcontrol.spwebensurespcontrol(httpcontext context)    @ microsoft.sharepoint.utilities.sputility.validateformdigest()    @ microsoft.sharepoint.administration.sppersistedobject.baseupdate()    @ microsoft.sharepoint.administration.sppersistedchildcollection`1.add(t newobj, boolean ensure)    @ microsoft.sharepoint.administration.sppersistedchildcollection`1.ensure(t newobj)    @ microsoft.sharepoint.administration.spcontentdatabasecollection.add(guid newdatabaseid, string strdatabaseserver, string strdatabasename, string strdatabaseusername, string strdatabasepassword, int32 warningsitecount, int32 maximumsitecount, int32 status, boolean provision, guid lockid, int32 addflags)    @ microsoft.sharepoint.administration.spcontentdatabasecollection.add(string strdatabaseserver, string strdatabasename, string strdatabaseusername, string strdatabasepassword, int32 warningsitecount, int32 maximumsitecount, int32 status)    @ niks.sp2010.sphostedwcfservice1.sphostedwcfservice.<createcontentdb>b__7()    @ microsoft.sharepoint.spsecurity.<>c__displayclass4.<runwithelevatedprivileges>b__2()    @ microsoft.sharepoint.utilities.securitycontext.runasprocess(codetorunelevated securecode)    @ microsoft.sharepoint.spsecurity.runwithelevatedprivileges(waitcallback securecode, object param)    @ microsoft.sharepoint.spsecurity.runwithelevatedprivileges(codetorunelevated securecode)    @ niks.sp2010.sphostedwcfservice1.sphostedwcfservice.createcontentdb()    @ niks.sp2010.sphostedwcfservice1.sphostedwcfservice.<>c__displayclass3.<getname>b__1()    @ microsoft.sharepoint.spsecurity.<>c__displayclass4.<runwithelevatedprivileges>b__2()    @ microsoft.sharepoint.utilities.securitycontext.runasprocess(codetorunelevated securecode)    @ microsoft.sharepoint.spsecurity.runwithelevatedprivileges(waitcallback securecode, object param)    @ microsoft.sharepoint.spsecurity.runwithelevatedprivileges(codetorunelevated securecode)    @ niks.sp2010.sphostedwcfservice1.sphostedwcfservice.getname() 

this error described in above link bolg.sharedove.com. think need set following code described in bolg.sharedove.com

var storecontext = httpcontext.current;  httpcontext.current = null;  // code  httpcontext.current = storecontext; 

i thnik can not set above code in wcf service. tried set in asp.net application same error has occured. can anuone please tell should set code ? if having different solution please share.

i added reference system.web.dll in wcf service application. can use httpcontext in wcf. have set following code in wcf

var storecontext = httpcontext.current;  httpcontext.current = null;  // code  httpcontext.current = storecontext; 

now code in wcf working fine. able create content database , site collection programatically.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -