摘要:[MOSS 2007] 解决Operation is not valid due to the current state of the object.
说明:在写Web Service的时候,使用到了SPSecurity.RunWithElevatedPrivileges而产生的消息
解决:
将原本
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://SiteUrl"))
{
using (SPWeb web = site.OpenWeb())
{
......
}
}
});
改为
SPWeb web = null;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://SiteUrl"))
{
web = site.OpenWeb();
......
}
});
web.Dispose();
也就是将SPWeb独立出来,不要放在SPSecurity.RunWithElevatedPrivileges里面
原文:大专栏 [MOSS 2007] 解决Web Service之Operation is not valid due to the current state of the object.