我有以下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;
}
}
错误:
在Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAsStream(字符串bstrUrl,字符串bstrWebRelativeUrl,布尔bHonorLevel,字节iLevel,OpenBinaryFlags grfob,字符串bstrEtagNotMatch,对象punkSPFileMgr,布尔bHonorCustomIrm,IrmProtectionParams fileIrmSettings,字符串&安培; pEtagNew,字符串&安培; pContentTagNew,SPFileInfo&安培; pFileProps)
在Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(字符串bstrUrl,字符串bstrWebRelativeUrl,布尔bHonorLevel,字节iLevel,OpenBinaryFlags grfob,字符串bstrEtagNotMatch,对象punkSPFileMgr,布尔bHonorCustomIrm,IrmProtectionParams fileIrmSettings,字符串&安培; pEtagNew,字符串&安培; pContentTagNew,SPFileInfo&安培; pFileProps)---内部异常堆栈跟踪结束---
at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
在Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(字符串bstrUrl,字符串bstrWebRelativeUrl,布尔bHonorLevel,字节iLevel,OpenBinaryFlags grfob,字符串bstrEtagNotMatch,对象punkSPFileMgr,布尔bHonorCustomIrm,IrmProtectionParams fileIrmSettings,字符串&安培; pEtagNew,字符串&安培; pContentTagNew,SPFileInfo&安培; pFileProps)
at 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)
at Microsoft.SharePoint.SPFile.OpenBinary(SPOpenBinaryOptions openOptions)
at Microsoft.SharePoint.Administration.SPSolutionLanguagePack.GetSolutionInfoFromGallery(Guid siteId,Guid solutionId,String solutionHash,String& fileName,String& hash,Byte []& fileBytes)
at Microsoft.SharePoint.Administration.SPSolutionLanguagePack.CreateSolutionPackage(SPRequest request,Guid siteId,Guid solutionId,String solutionHash)
在Microsoft.SharePoint.UserCode上。 SPUserCodeLightweightSolutionAssemblyGroupProvider.GetAssembliesInGroup(Guid siteId,String assemblyGroupId)
at Microsoft.SharePoint.UserCode.SPUserCodeAssemblyCacheManager.EnsureUserCodeAssemblyGroupIsCached(Guid siteId,SPUserCodeAssemblyGroupId userCodeAssemblyGroupId)---内部异常堆栈跟踪结束---服务器堆栈跟踪:
at Microsoft.SharePoint.UserCode.SPUserCodeAssemblyCacheManager.EnsureUserCodeAssemblyGroupIsCached(Guid siteId,SPUserCodeAssemblyGroupId userCodeAssemblyGroupId)
at Microsoft.SharePoint.UserCode.SPUserCodeExecutionHost.Execute(输入userCodeWrapperType,Guid siteCollectionId,SPUserToken userToken,String affinity,SPUserCodeExecutionContext executionContext)
在System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md,Object [] args,Object server,Object []& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)异常重新抛出
在[0]:
在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type)
at Microsoft.SharePoint.Administration.ISPUserCodeExecutionHostProxy.Execute(输入userCodeWrapperType,Guid siteCollectionId,SPUserToken userToken,String affinityBucketName,SPUserCodeExecutionContext executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeExecutionManager.Execute(输入userCodeWrapperType,SPSite site,SPUserCodeExecutionContext executionContext)
答案 0 :(得分:1)
错误是由于我部署解决方案的方式造成的。 .dll文件未部署到GAC。
使用以下PowerShell重新部署.wsp文件后,一切正常。
Add-SPSolution -LiteralPath" C:\ Solution.wsp"
Install-SPSolution -Identity Solution.wsp -GACDeployment
答案 1 :(得分:0)
在我看来,您好像将其作为沙盒解决方案运行一样。这是设计还是您的目标是农场解决方案?
我看到两个选项:
如果您将此定位为沙盒解决方案,您是否尝试过调试它? 您可以从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 。