zoukankan      html  css  js  c++  java
  • INFOPATH 2007 System.InvalidOperationException: 对象的当前状态使该操作无效。

    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

    image

    将this.Application.User.LoginName提到RunWithElevatedPrivileges外面后,问题解决

  • 相关阅读:
    linux所有命令失效的解决办法
    第一章 网络基础知识
    RNQOJ 数列
    RNQOJ Jam的计数法
    RNQOJ 开心的金明
    RQNOJ 明明的随机数
    分类讨论的技巧
    Unity 碰撞检测
    Unity --yield return
    Unity 移动方式总结
  • 原文地址:https://www.cnblogs.com/scally/p/1549694.html
Copyright © 2011-2022 走看看