Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.InvalidOperationException:由于对象的当前状态,操作无效。? 我正在为SharePoint基金会2010开发ASP.NET MVC应用程序。ASP.NET应用程序托管在一台机器上,SharePoint Foundation 2010托管在另一台机器上。我在SharePoint环境的ISAPI文件夹中部署了一个自定义wcf服务。此自定义wcf服务以编程方式创建内容数据库。asp.net应用程序使用此自定义wcf服务。我使用这种方法是因为我的场景类似于链接-。执行上述场景时,我遇到了错误-。我已经用计算机解决了这个错误。现在我得到错误-System.InvalidOperationException:由于对象的当前状态,操作无效 System.InvalidOperationException: Operation is not valid due to the current state of the object. at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context) at Microsoft.SharePoint.Utilities.SPUtility.ValidateFormDigest() at Microsoft.SharePoint.Administration.SPPersistedObject.BaseUpdate() at Microsoft.SharePoint.Administration.SPPersistedChildCollection`1.Add(T newObj, Boolean ensure) at Microsoft.SharePoint.Administration.SPPersistedChildCollection`1.Ensure(T newObj) at 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) at Microsoft.SharePoint.Administration.SPContentDatabaseCollection.Add(String strDatabaseServer, String strDatabaseName, String strDatabaseUsername, String strDatabasePassword, Int32 warningSiteCount, Int32 maximumSiteCount, Int32 status) at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.<createContentDb>b__7() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.createContentDb() at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.<>c__DisplayClass3.<GetName>b__1() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.GetName()_C#_Wcf_Sharepoint 2010_Sharepoint Object Model - Fatal编程技术网

C# System.InvalidOperationException:由于对象的当前状态,操作无效。? 我正在为SharePoint基金会2010开发ASP.NET MVC应用程序。ASP.NET应用程序托管在一台机器上,SharePoint Foundation 2010托管在另一台机器上。我在SharePoint环境的ISAPI文件夹中部署了一个自定义wcf服务。此自定义wcf服务以编程方式创建内容数据库。asp.net应用程序使用此自定义wcf服务。我使用这种方法是因为我的场景类似于链接-。执行上述场景时,我遇到了错误-。我已经用计算机解决了这个错误。现在我得到错误-System.InvalidOperationException:由于对象的当前状态,操作无效 System.InvalidOperationException: Operation is not valid due to the current state of the object. at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context) at Microsoft.SharePoint.Utilities.SPUtility.ValidateFormDigest() at Microsoft.SharePoint.Administration.SPPersistedObject.BaseUpdate() at Microsoft.SharePoint.Administration.SPPersistedChildCollection`1.Add(T newObj, Boolean ensure) at Microsoft.SharePoint.Administration.SPPersistedChildCollection`1.Ensure(T newObj) at 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) at Microsoft.SharePoint.Administration.SPContentDatabaseCollection.Add(String strDatabaseServer, String strDatabaseName, String strDatabaseUsername, String strDatabasePassword, Int32 warningSiteCount, Int32 maximumSiteCount, Int32 status) at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.<createContentDb>b__7() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.createContentDb() at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.<>c__DisplayClass3.<GetName>b__1() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.GetName()

C# System.InvalidOperationException:由于对象的当前状态,操作无效。? 我正在为SharePoint基金会2010开发ASP.NET MVC应用程序。ASP.NET应用程序托管在一台机器上,SharePoint Foundation 2010托管在另一台机器上。我在SharePoint环境的ISAPI文件夹中部署了一个自定义wcf服务。此自定义wcf服务以编程方式创建内容数据库。asp.net应用程序使用此自定义wcf服务。我使用这种方法是因为我的场景类似于链接-。执行上述场景时,我遇到了错误-。我已经用计算机解决了这个错误。现在我得到错误-System.InvalidOperationException:由于对象的当前状态,操作无效 System.InvalidOperationException: Operation is not valid due to the current state of the object. at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context) at Microsoft.SharePoint.Utilities.SPUtility.ValidateFormDigest() at Microsoft.SharePoint.Administration.SPPersistedObject.BaseUpdate() at Microsoft.SharePoint.Administration.SPPersistedChildCollection`1.Add(T newObj, Boolean ensure) at Microsoft.SharePoint.Administration.SPPersistedChildCollection`1.Ensure(T newObj) at 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) at Microsoft.SharePoint.Administration.SPContentDatabaseCollection.Add(String strDatabaseServer, String strDatabaseName, String strDatabaseUsername, String strDatabasePassword, Int32 warningSiteCount, Int32 maximumSiteCount, Int32 status) at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.<createContentDb>b__7() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.createContentDb() at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.<>c__DisplayClass3.<GetName>b__1() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Niks.SP2010.SPHostedWCFService1.SPHostedWCFService.GetName(),c#,wcf,sharepoint-2010,sharepoint-object-model,C#,Wcf,Sharepoint 2010,Sharepoint Object Model,我无法在wcf服务中设置上述代码。我试图在asp.net应用程序中设置它,但发生了相同的错误。请告诉我在哪里设置这个代码好吗?如果有人有不同的解决方案,请分享。我只是在wcf服务应用程序中添加了对System.Web.dll的引用。现在我可以在wcf中使用HttpContext了。我在wcf中设置了以下代码 var storeContext = HttpContext.Current; HttpContext.Current = null; // do your code HttpCont

我无法在wcf服务中设置上述代码。我试图在asp.net应用程序中设置它,但发生了相同的错误。请告诉我在哪里设置这个代码好吗?如果有人有不同的解决方案,请分享。

我只是在wcf服务应用程序中添加了对System.Web.dll的引用。现在我可以在wcf中使用HttpContext了。我在wcf中设置了以下代码

var storeContext = HttpContext.Current; 
HttpContext.Current = null; 
// do your code 
HttpContext.Current = storeContext;
现在wcf中的所有代码都工作正常。我现在能够以编程方式创建内容数据库和网站集

var storeContext = HttpContext.Current; 
HttpContext.Current = null; 
// do your code 
HttpContext.Current = storeContext;