INFOPATH 2007 - System.InvalidOperationException: 对象的当前状态使该操作无效。
2009-08-19 11:33
751 查看
List<string> ReturnDepList()
{
List<string> values = new List<string>();
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (MossTools m = new MossTools(Config.WebUrl))
{
//此行报错
values = m.getFieldWithPerson(Config.SendDepListName, m.GetUser(this.Application.User.LoginName).ID, "单位文件夹", "单位负责人", "单位联系人");
}
});
return values;
}
错误信息:
对象的当前状态使该操作无效。
System.InvalidOperationException: 对象的当前状态使该操作无效。
在 Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context)
在 Microsoft.SharePoint.WebControls.SPControl.GetContextWeb(HttpContext context)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.GetCurrentUser()
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.<>c__DisplayClass1.<get_CurrentUser>b__0()
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.ExecuteOMCallWithExceptions(OMCall d, ExceptionFilter exceptionFilter)
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, ExceptionFilter exceptionFilter, OMCall d)
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, OMCall d)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.get_CurrentUser()
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.<>c__DisplayClass4.<get_LoginName>b__3()
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.ExecuteOMCallWithExceptions(OMCall d, ExceptionFilter exceptionFilter)
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, ExceptionFilter exceptionFilter, OMCall d)
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, OMCall d)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.get_LoginName()
在备忘备.FormCode.<>c__DisplayClass1.<ReturnDepList>b__0() 位置 C:\Documents and Settings\Administrator.SCALLY\My Documents\InfoPath 项目\SendDocument1\FormCode.cs:行号 1250
在 Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state)
在 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)
在备忘备.FormCode.ReturnDepList() 位置 C:\Documents and Settings\Administrator.SCALLY\My Documents\InfoPath 项目\SendDocument1\FormCode.cs:行号 1246
在备忘备.FormCode.FormEvents_Loading(Object sender, LoadingEventArgs e) 位置 C:\Documents and Settings\Administrator.SCALLY\My Documents\InfoPath 项目\SendDocument1\FormCode.cs:行号 74
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<>c__DisplayClassa.<add_Loading>b__3()
在 Microsoft.Office.InfoPath.Server.Util.DocumentReliability.InvokeBusinessLogic(Thunk thunk)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<add_Loading>b__2(Object sender, LoadingEventArgs e)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass34.<FireLoadingEvent>b__30()
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.CallFormCodeWithExceptionHandling(UserMessages userMessages, OMCall d)
已向服务器的 Windows 事件日志中添加了一个条目。
日志 ID:5337
将this.Application.User.LoginName提到RunWithElevatedPrivileges外面后,问题解决
{
List<string> values = new List<string>();
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (MossTools m = new MossTools(Config.WebUrl))
{
//此行报错
values = m.getFieldWithPerson(Config.SendDepListName, m.GetUser(this.Application.User.LoginName).ID, "单位文件夹", "单位负责人", "单位联系人");
}
});
return values;
}
错误信息:
对象的当前状态使该操作无效。
System.InvalidOperationException: 对象的当前状态使该操作无效。
在 Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context)
在 Microsoft.SharePoint.WebControls.SPControl.GetContextWeb(HttpContext context)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.GetCurrentUser()
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.<>c__DisplayClass1.<get_CurrentUser>b__0()
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.ExecuteOMCallWithExceptions(OMCall d, ExceptionFilter exceptionFilter)
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, ExceptionFilter exceptionFilter, OMCall d)
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, OMCall d)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.get_CurrentUser()
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.<>c__DisplayClass4.<get_LoginName>b__3()
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.ExecuteOMCallWithExceptions(OMCall d, ExceptionFilter exceptionFilter)
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, ExceptionFilter exceptionFilter, OMCall d)
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, OMCall d)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.UserHost.get_LoginName()
在备忘备.FormCode.<>c__DisplayClass1.<ReturnDepList>b__0() 位置 C:\Documents and Settings\Administrator.SCALLY\My Documents\InfoPath 项目\SendDocument1\FormCode.cs:行号 1250
在 Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state)
在 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)
在备忘备.FormCode.ReturnDepList() 位置 C:\Documents and Settings\Administrator.SCALLY\My Documents\InfoPath 项目\SendDocument1\FormCode.cs:行号 1246
在备忘备.FormCode.FormEvents_Loading(Object sender, LoadingEventArgs e) 位置 C:\Documents and Settings\Administrator.SCALLY\My Documents\InfoPath 项目\SendDocument1\FormCode.cs:行号 74
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<>c__DisplayClassa.<add_Loading>b__3()
在 Microsoft.Office.InfoPath.Server.Util.DocumentReliability.InvokeBusinessLogic(Thunk thunk)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<add_Loading>b__2(Object sender, LoadingEventArgs e)
在 Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass34.<FireLoadingEvent>b__30()
在 Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.CallFormCodeWithExceptionHandling(UserMessages userMessages, OMCall d)
已向服务器的 Windows 事件日志中添加了一个条目。
日志 ID:5337
将this.Application.User.LoginName提到RunWithElevatedPrivileges外面后,问题解决
相关文章推荐
- System.InvalidOperationException: 对象的当前状态使该操作无效
- System.InvalidOperationException: 对象的当前状态使该操作无效
- 异常详细信息: System.InvalidOperationException: 对象的当前状态使该操作无效 真正的解决办法
- System.InvalidOperationException: 对象的当前状态使该操作无效 【大量表单数据提交】
- 异常: System.InvalidOperationException: 对象的当前状态使该操作无效
- System.InvalidOperationException: 对象的当前状态使该操作无效
- System.InvalidOperationException: 对象的当前状态使该操作无效。
- 【ASP.NET 问题】System.InvalidOperationException: 对象的当前状态使该操作无效 【大量表单数据提交】错误解决
- 异常详细信息: System.InvalidOperationException: 对象的当前状态使该操作无效
- [InvalidOperationException: 对象的当前状态使该操作无效
- InvalidOperationException: 对象的当前状态使该操作无效
- InvalidOperationException: 对象的当前状态使该操作无效
- 【探索发现】System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException 对象的当前状态使该操作无效。
- [System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException]: {"对象的当前状态使该操作无效。"}
- 对象的当前状态使该操作无效 or SPListItem Update Operation is not valid due to the current state of the object
- SPListItem Update Operation is not valid due to the current state of the object(对象的当前状态使该操作无效。)
- 线程使用中常见的错误-“System.InvalidOperationException”线程间操作无效: 从不是创建控件“ ”的线程访问它。
- {System.InvalidOperationException: 无效操作。连接被关闭。
- (转)InvalidOperationException: 对象的当前状态使该操作无效
- System.InvalidOperationException:“线程间操作无效: 从不是创建控件“txtPortName02”的线程访问它。”