R – Sharepoint workflow fails after upgrading solution

sharepointsharepoint-2007wss-3.0

I have a running workflow that is using both the parallell and OnTaskCreated Activities. The solution has bee deployed at multiple clients, I was recently working on an upgrade which required to swap out the workflow assembly. I had some running workflow instances on the server when I did the upgrade.

Since then nothing has been working, I can't seem to geta a new workflow finishing normally. I always gets this error here:

01/14/2010 16:14:33.73  w3wp.exe (0x1928)                           0x2514  Windows SharePoint Services     Workflow Infrastructure         936l    High        Engine RunWorkflow: System.Workflow.Activities.EventDeliveryFailedException: Event "OnTaskChanged" on interface type "Microsoft.SharePoint.Workflow.ITaskService" for instance id "7697ee64-7286-46f3-992e-cf3c18731f15" cannot be delivered. ---> System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.SharePoint.Workflow.SPWorkflowHostServiceBase.LoadInstanceData(Guid instanceId, Boolean& compressedData)     at Microsoft.SharePoint.Workflow.SPWinOePersistenceService.LoadWorkflowInstanceState(Guid instanceId)     at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance)     at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationCont...  
01/14/2010 16:14:33.73* w3wp.exe (0x1928)                           0x2514  Windows SharePoint Services     Workflow Infrastructure         936l    High        ...ext context, WorkflowInstance workflowInstance)     at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)     at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)     --- End of inner exception stack trace ---     at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)     at Microsoft.SharePoint.Workflow.SPWinOETaskService.RaiseEvent(SPWinOeWorkflow workflow, SPWorkflowEvent workflowEvent, Object workItem, IPendingWork workHandler)     at Microsoft.SharePoint.Workflow.SPWinOeHostServices.Send(SPWinOeWorkflow winoeworkflow, SPWorkflowEvent e)     at Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWorkflow(Guid trackingId, SPWorkflowHostService ho...   
01/14/2010 16:14:33.73* w3wp.exe (0x1928)                           0x2514  Windows SharePoint Services     Workflow Infrastructure         936l    High        ...st, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)   

I've been googling the problem and I've found multiple solutions where people are advising to terminate all workflow instances before the upgrade is made. In my opinion that solution is not acceptable, because I could have an unmanagable number of running workflows.

I was wondering if this might be related to the Sharepoint Workflow Host, can I terminate all running workflow programmatically during upgrade ?

Does someone have an idea how I can solve this issue ?

Best Answer

You should have listened to those people, or at the very least investigated for yourself why they are saying these things. They are right, and now you know why; you have effectively screwed all of your running workflows.

SharePoint serializes a binary workflow to the database when the workflow is inactive/idle and/or waiting for an event. If you swap out the assembly while it is sleeping/serialized, when the WF hosting infrastructure in sharepoint tries to deserialize the workflow to revive it, it will fail because the target type has changed (because you "upgraded" it.)

There is NO easy way to upgrade binary workflows in sharepoint; side-by-side is the only manageable way to do it. You bump the assembly version, create a new WF assocation and set the old wrkflow associations to stop accepting new requests. The old workflows will complete with the old code, and new workflows use your new code. No other way, sorry.

-Oisin

Related Topic