InvalidOperationException “The event receiver context for Workflow is invalid” Problems with onTaskChanged in a SharePoint Workflow

If you’re dropping a onTaskChanged activity and you’re finding an event in the ULS like the following …

11/30/2006 08:56:04.12  OWSTIMER.EXE (0x05D4)                    0x0B48 Windows SharePoint Services    Workflow Infrastructure        72er Medium   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)

Help Your SharePoint User

The problem may no with the event receiver, rather that in the CreateTask activity you didn’t associate properties for TaskID, TaskProperties, or CorrelationToken.  Thus there’s no context for the event to call back to.