Reputation: 53
I have the following SharePoint 2013 list event receiver. When the receiver runs on item updating it throws a error. The error below is from the SharePoint ULS logs. Has anyone encountered this before, and/or know how to resolve it?
Code:
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;
}
}
Error:
at Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, Object punkSPFileMgr, Boolean bHonorCustomIrm, IrmProtectionParams fileIrmSettings, String& pEtagNew, String& pContentTagNew, SPFileInfo& pFileProps)
at Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, Object punkSPFileMgr, Boolean bHonorCustomIrm, IrmProtectionParams fileIrmSettings, String& pEtagNew, String& pContentTagNew, SPFileInfo& pFileProps) --- End of inner exception stack trace ---
at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
at Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, Object punkSPFileMgr, Boolean bHonorCustomIrm, IrmProtectionParams fileIrmSettings, String& pEtagNew, String& 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)
at Microsoft.SharePoint.UserCode. SPUserCodeLightweightSolutionAssemblyGroupProvider.GetAssembliesInGroup(Guid siteId, String assemblyGroupId)
at Microsoft.SharePoint.UserCode.SPUserCodeAssemblyCacheManager.EnsureUserCodeAssemblyGroupIsCached(Guid siteId, SPUserCodeAssemblyGroupId userCodeAssemblyGroupId) --- End of inner exception stack trace --- Server stack trace:
at Microsoft.SharePoint.UserCode.SPUserCodeAssemblyCacheManager.EnsureUserCodeAssemblyGroupIsCached(Guid siteId, SPUserCodeAssemblyGroupId userCodeAssemblyGroupId)
at Microsoft.SharePoint.UserCode.SPUserCodeExecutionHost.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) Exception rethrown
at [0]:
at 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(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinityBucketName, SPUserCodeExecutionContext executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeExecutionManager.Execute(Type userCodeWrapperType, SPSite site, SPUserCodeExecutionContext executionContext)
Upvotes: 1
Views: 2373
Reputation: 53
The error was caused because of the way I was deploying the solution. The .dll files were not being deployed to the GAC.
Once I redeployed the .wsp file using the following PowerShell everything worked correctly.
Add-SPSolution -LiteralPath "C:\Solution.wsp"
Install-SPSolution -Identity Solution.wsp -GACDeployment
Upvotes: 1
Reputation: 66
It looks to me as if you're running this as a Sandboxed solution. Is this by design or were you aiming for a Farm solution?
I see two options:
If you are targeting this as a Sandboxed solution, have you tried debugging it? You can attach the debugger from Visual Studio to debug the event receiver so you can see where things go wrong.
Debugging event receiver (Farm Solution): http://social.msdn.microsoft.com/Forums/sharepoint/en-US/2cd71336-d971-4387-a50f-9b4c63801678/debugging-sharepoint-event-receivers
Note that this link is for a Farm solution (the W3WP process). If you need to attach the UserCode (Sandbox) process instead, it is called SPUCWorkerProcess.exe.
Upvotes: 0