我有以下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: Cannot complete this action。请再试一次。System.Runtime.InteropServices.COMException: Cannot complete this action。请再试一次。0 x80004005
。GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte illevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, Object punkSPFileMgr, Boolean bHonorCustomIrm, IrmProtectionParams fileIrmSettings, String&pEtagNew String&pContentTagNew SPFileInfo&pFileProps)
在Microsoft.SharePoint.Library.SPRequest。GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte illevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, Object punkSPFileMgr, Boolean bHonorCustomIrm, IrmProtectionParams fileIrmSettings, String&pEtagNew String&pContentTagNew SPFileInfo&pFileProps)——内部异常堆栈跟踪结束——
在Microsoft.SharePoint.SPGlobal。HandleComException(COMException comEx)
在Microsoft.SharePoint.Library.SPRequest。GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte illevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, Object punkSPFileMgr, Boolean bHonorCustomIrm, IrmProtectionParams fileIrmSettings, String&pEtagNew String&pContentTagNew SPFileInfo&pFileProps)
在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&文件名,String&散列,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) Exception rethrown
at [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。执行(类型userCodeWrapperType, SPSite site, SPUserCodeExecutionContext executionContext)
错误是由于我部署解决方案的方式造成的。.dll文件没有部署到GAC。
一旦我使用以下PowerShell重新部署。wsp文件,一切都正常工作。
Add-SPSolution -LiteralPath "C:Solution.wsp"
Install-SPSolution -Identity Solution。wsp -GACDeployment
在我看来,好像您正在将此作为沙盒解决方案运行。这是你的设计还是你想要一个农场解决方案?
我看到两个选项:
- 调试当前的接收器(沙盒?),看看会发生什么。
- 切换到农场解决方案,看看会发生什么。
如果您将此作为沙盒解决方案,您是否尝试过调试它?你可以从Visual Studio中附加调试器来调试事件接收器,这样你就可以看到哪里出错了。
调试事件接收器(Farm Solution): http://social.msdn.microsoft.com/Forums/sharepoint/en-US/2cd71336-d971-4387-a50f-9b4c63801678/debugging-sharepoint-event-receivers
请注意,此链接适用于场解决方案(W3WP进程)。如果需要附加UserCode (Sandbox)进程,则称为SPUCWorkerProcess.exe。