The event receiver context for Workflow is invalid
Ok, another Sharepoint strange error. In my workflow I am getting this error:
System.InvalidOperationException: The event receiver context for Workflow is invalid.
at Microsoft.SharePoint.SPEventReceiverDefinition.ValidContext() at
icrosoft.SharePoint.SPEventReceiverDefinition.ValidReceiverFields() at Microsoft.SharePoint.SPEventReceiverDefinition.GetSqlCommandToAddEventReceivers(IList`1 erds) at Microsoft.SharePoint.Workflow.SPWinOESubscriptionService.CommitNewSubscriptions(Transaction txn, IList`1 erds)
this is when I wait for onTaskChange event. Everywhere on the internet people say that this happens when either correlation token or taskid are not set properly, however I've triple checked and even rebuilt from scratch and yet the same error.
And the weird thing is that once it helped if I moved the whole thing before a logtoHistory activity and not after it. I mean, that just doesn't make any sense to me.
With this case however, there is no logtohistory event and nothing I do gets me pas开发者_开发问答t the problem.
UPDATE: I found out this happens as soon as I bind afterproperties of the onTaskChange activity. ???
UPDATE: here is the image of the part of workflow that is giving me trouble:
More and more it looks like some kind of designer bug in connection with correlation tokens. If i create a new task token on the createTask and then assign it to update task, oncreated and onchange task, but not CompleteTask it will work ok, until complete task (as expected), but if I also set the new token to the complete task it will fail on onChangeTask. If I delete the completeTask it will fail on the onChangeTask. WTF??
There might be a problem with correlation tokens here. Are you using a different correlation token than the one used for the whole workflow?
EDIT: Another question - are you setting the TaskID property of the task in your code?
In my custom activities, I always bind the TaskID
property of the CreateTask
activity to a local field icTaskID. Then, I add a en event handler to the CreateTask activitie's methodInvoking event and inside that event, do the following
Me.icVisaTaskID = Guid.NewGuid
精彩评论