【问题标题】:SharePoint 2013 Event Receiver ErrorSharePoint 2013 事件接收器错误
【发布时间】:2014-09-29 19:06:52
【问题描述】:

我有以下 SharePoint 2013 列表事件接收器。当接收器在项目更新上运行时,它会引发错误。下面的错误来自 SharePoint ULS 日志。有没有人遇到过这个问题,和/或知道如何解决它?

代码:

    public override void ItemUpdating(SPItemEventProperties properties)
    {
        try
        {
            base.ItemUpdating(properties);

            properties.Status = SPEventReceiverStatus.CancelWithError;
            properties.ErrorMessage = "You cannot updated a approved requisition";
        }
        catch (Exception ex)
        {
            properties.Status = SPEventReceiverStatus.CancelWithError;
            properties.ErrorMessage = ex.Message.ToString() + " Stack Trace -" 
                 + ex.StackTrace + "Inner Exception -" + ex.InnerException;
        }
    }

错误:

  • UserCodeExecutionProxy 调用失败。 Microsoft.SharePoint.UserCode.SPUserCodeExecutionPipelineFailedException:无法加载程序集组。用户程序集组提供程序在尝试为指定程序集组提供用户程序集时引发异常。 ---> Microsoft.SharePoint.SPException:无法完成此操作。请再试一次。 ---> System.Runtime.InteropServices.COMException:无法完成此操作。请再试一次。0x80004005

在 Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAsStream(字符串 bstrUrl,字符串 bstrWebRelativeUrl,布尔 bHonorLevel,字节 iLevel,OpenBinaryFlags grfob,字符串 bstrEtagNotMatch,对象 punkSPFileMgr,布尔 bHonorCustomIrm,IrmProtectionParams 文件IrmSettings,字符串和 pEtagNew,字符串和 pContentTagNew,SPFileInfo)

在 Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(字符串 bstrUrl,字符串 bstrWebRelativeUrl,布尔 bHonorLevel,字节 iLevel,OpenBinaryFlags grfob,字符串 bstrEtagNotMatch,对象 punkSPFileMgr,布尔 bHonorCustomIrm,IrmProtectionParams 文件IrmSettings,字符串和 pEtagNew,字符串和 pContentTagNew,SPFileInfo 和 pFilePro) --- 内部异常堆栈跟踪结束 ---

在 Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)

在 Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(字符串 bstrUrl,字符串 bstrWebRelativeUrl,布尔 bHonorLevel,字节 iLevel,OpenBinaryFlags grfob,字符串 bstrEtagNotMatch,对象 punkSPFileMgr,布尔 bHonorCustomIrm,IrmProtectionParams 文件IrmSettings,字符串和 pEtagNew,字符串和 pContentTagNew,SPFileInfo 和 pFilePro)

在 Microsoft.SharePoint.SPFile.GetFileStream(SPWeb web, String fileUrl, Boolean HonorLevel, SPFileLevel level, OpenBinaryFlags openOptions, String etagNotMatch, SPFileStreamManager spMgr, SPFileRightsManagementSettings rightsManagementSettings, String& etagNew, String& contentTagNew, SPFileInfo& fileprops)

在 Microsoft.SharePoint.SPFile.OpenBinary(SPOpenBinaryOptions openOptions)

在 Microsoft.SharePoint.Administration.SPSolutionLanguagePack.GetSolutionInfoFromGallery(Guid siteId, Guid solutionId, String solutionHash, String& fileName, String& hash, Byte[]& fileBytes)

在 Microsoft.SharePoint.Administration.SPSolutionLanguagePack.CreateSolutionPackage(SPRequest request, Guid siteId, Guid solutionId, String solutionHash)

在 Microsoft.SharePoint.UserCode。 SPUserCodeLightweightSolutionAssemblyGroupProvider.GetAssembliesInGroup(Guid siteId, String assemblyGroupId)

在 Microsoft.SharePoint.UserCode.SPUserCodeAssemblyCacheManager.EnsureUserCodeAssemblyGroupIsCached(Guid siteId, SPUserCodeAssemblyGroupId userCodeAssemblyGroupId) --- 内部异常堆栈跟踪结束 --- 服务器堆栈跟踪:

在 Microsoft.SharePoint.UserCode.SPUserCodeAssemblyCacheManager.EnsureUserCodeAssemblyGroupIsCached(Guid siteId, SPUserCodeAssemblyGroupId userCodeAssemblyGroupId)

在 Microsoft.SharePoint.UserCode.SPUserCodeExecutionHost.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext)

在 System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)

在 System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) 异常重新抛出

在 [0]:

在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 类型)

在 Microsoft.SharePoint.Administration.ISPUserCodeExecutionHostProxy.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinityBucketName, SPUserCodeExecutionContext executionContext)

在 Microsoft.SharePoint.UserCode.SPUserCodeExecutionManager.Execute(键入 userCodeWrapperType,SPSite 站点,SPUserCodeExecutionContext executionContext)

【问题讨论】:

    标签: c# .net sharepoint sharepoint-2013


    【解决方案1】:

    该错误是由我部署解决方案的方式引起的。 .dll 文件未部署到 GAC。

    使用以下 PowerShell 重新部署 .wsp 文件后,一切正常。

    添加-SPSolution -LiteralPath "C:\Solution.wsp"

    Install-SPSolution -Identity Solution.wsp -GACDeployment

    【讨论】:

      【解决方案2】:

      在我看来,您将其作为沙盒解决方案运行。这是设计使然,还是您的目标是农场解决方案?

      我看到两个选项:

      • 调试您当前的接收器(沙盒?),看看会发生什么。
      • 切换到农场解决方案,看看会发生什么。

      如果您将此作为沙盒解决方案的目标,您是否尝试过对其进行调试? 您可以从 Visual Studio 附加调试器来调试事件接收器,以便查看哪里出了问题。

      调试事件接收器(农场解决方案):http://social.msdn.microsoft.com/Forums/sharepoint/en-US/2cd71336-d971-4387-a50f-9b4c63801678/debugging-sharepoint-event-receivers

      请注意,此链接适用于 Farm 解决方案(W3WP 流程)。如果您需要附加 UserCode (Sandbox) 进程,则称为 SPUCWorkerProcess.exe

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-04-07
        • 1970-01-01
        • 1970-01-01
        • 2012-11-14
        • 1970-01-01
        • 2014-08-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多