Error
I ran into an interesting error when building up some WF State Machine Workflows for SharePoint. I had no problems building some sequential workflows and then I started building a fairly complex State Machine Workflow and I got a really useless error message that gave me no insight at all:
Value cannot be null
System.InvalidOperationException: The event receiver context for Workflow is invalid. at Microsoft.SharePoint.SPEventReceiverDefinition.ValidContext() at Microsoft.SharePoint.SPEventReceiverDefinition.ValidReceiverFields() at Microsoft.SharePoint.SPEventReceiverDefinition.GetSqlCommandToAddEventReceivers(IList`1 erds) at Microsoft.SharePoint.Workflow.SPWinOESubscriptionService.CommitNewSubscriptions(Transaction txn, IList`1 erds)
Error in commiting pending workflow batch items: System.InvalidOperationException: The event receiver context for Workflow is invalid. at Microsoft.SharePoint.SPEventReceiverDefinition.ValidContext() at Microsoft.SharePoint.SPEventReceiverDefinition.ValidReceiverFields() at Microsoft.SharePoint.SPEventReceiverDefinition.GetSqlCommandToAddEventReceivers(IList`1 erds) at Microsoft.SharePoint.Workflow.SPWinOESubscriptionService.CommitNewSubscriptions(Transaction txn, IList`1 erds) at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.ProcessWorkItemBatch(Transaction transaction, Work method, IList`1 workItemBatch) at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.Commit(Transaction transaction, ICollection items)
I did some searching and came up with some links but none of them helped:
- http://social.msdn.microsoft.com/forums/en-US/sharepointworkflow/thread/307e4dd9-4120-4e81-ae0e-26dfb5483b39/
- http://www.novolocus.com/2007/09/11/error-the-event-receiver-context-for-workflow-is-invalid/
- http://social.msdn.microsoft.com/forums/en-US/sharepointworkflow/thread/722d4beb-7bad-4928-bf01-03dbf9926b1d/
- http://www.thorprojects.com/blog/archive/2006/11/30/invalidoperationexception-quote-the-event-receiver-context-for-workflow-is-invalid-quote-problems-with-ontaskchanged-in-a-sharepoint-workflow.aspx
Resolution
If you are getting this error basically you have somehow messed up the TaskID, TaskProperties, AfterProperties, BeforeProperties, or even your CorrelationTokens. When I say messed up, these values have probably not been initialized correctly.
In my case, I had forgot to do TaskId = Guid.NewGuid(); in one of my CreateTask event handlers and bam, I got this error.
No comments:
Post a Comment