Workflow versioning issues with eventing (External Data Exchange) and tracking services

Last Summer, I came across an interesting problem on wrokflow versioning. It included versioning for ExternalDataExchange and tracking service. There's a simple fix for workflow and ExternalDataExchange but tracking service versioning issue could be fixed only through a hot fix. Please see below for more details. 

You  have a simple test state machine workflow with Started state, an Approved state, a Rejected state, and a Completed state. Each state has a corresponding event handler that is used to transition from state to state by raising the appropriate event. Host application is an ASP.Net web application and the workflow assembly is put in GAC. It all works and then you create a few instances of the workflow, transition them to the Started state, and then decide to add a Canceled state. Now, re-version the assembly to, place a copy in the GAC, create a few instances of the new workflow. The problem occurs when you try to go back and re-hydrate a workflow created under my workflow ver. If you try to transition the workflow to the Approved state from the Started state, the following error occurs:

Event Queue operation failed with MessageQueueErrorCode QueueNotFound for queue
'Message Properties
Interface Type:Workflows.IApprove
Method Name:Approved

So, the question is: how do i version the workflow so that the workflow persisted using the older assemblies still works?

Solution 1: It is standard .net versioning, so you can do it any way that you would do it with non workflow assemblies that you need to version:

You can register them as side by side in the gac or keep them in private folders. You can use TypeProvider to make sure that they are available to the runtime, like this:

TypeProvider typeProvider = new TypeProvider(wfruntime);
Assembly wf1 = Assembly.LoadFrom(Path.Combine(Files, "Workflow1.dll")); // this
could be the old version
wfruntime.AddService(typeProvider); // now WF Runtime can find the old version when it needs it

Solution 2: A much better soulution would be:
Configure for assemly binding re-redirection through the configuration file.


<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
 <assemblyIdentity name="Workflows" publicKeyToken="a62305a49c4d454f" culture="neutral" />
 <bindingRedirect oldVersion="" newVersion=""/>

However, in ASP.Net application make sure that start of web.config file is "<configuration>" instead of "<configuration xmlns="<>"

Solution for versioining issue with custom tracking service:

You also see the above exception when a custom tracking service that tracks persisted workflows in Windows Workflow Foundation is updgraed to a newer version and the persisted workflows do not run. Please see the below article for more information.

956630 FIX: Persisted workflows do not run after you upgrade the tracking service to a newer version in Windows Workflow Foundation;EN-US;956630