Thursday, October 23, 2008

System.InvalidOperationException: The event receiver context for Workflow is invalid.

If the below error come up while creating sharepoint worflow:

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)


The cause of this is either you didn't associate properties for TaskID, TaskProperties, or CorrelationToken activity to your createtask token. The other scenario that this comes up is when you don't assign a unique id to your Taskid. If you code looks like below:
public Guid createTaskInitiation_TaskId = default(System.Guid);
to
public Guid createTaskInitiation_TaskId = Guid.Newguid();
This should resolve the error.

No comments: