Workflow tracking database BUG when using WorkflowChanges
*Moved to: http://fluentbytes.com/workflow-tracking-database-bug-when-using-workflowchanges/
Today I ran into another bug related to SQL tracking. We have a workflow that changes it's implementation based on settings from the database. So what we do is use the WorkflowChanges object and modify the activity tree and apply the changes. Nothing fancy, just simple workflow stuff fully documented.
We use the WorkflowMonitor to provide our Administrators with a tool to see when a workflow failed why that happened. But where we ran into is the fact that the Monitor did not show our workflows any more. We ran into an exception every time we used the SqlTrackingWorkflowInstance. WorkflowDefinition. The execption we got was a WorkflowMarkupSerializationException.
When we took a closer look we found that the inner exception contained detailed information that the XML was not valid. Now that is ofcourse strange, since we did not do anything to manipulate this XML.
After some digging arround we found that when you apply dynamic changes, this is nicely administered in the SQL Tracking database table AddedActivity.
This Table has a column called AddedActivityAction that has a size of 2000. this column contains information on the change that is done to the workflow. this is a XAML string that contains the object tree of the added activity and the bindings to the activity properties.
It apeared that the changes we apply, do not fit into this string of 2000 characters! This is caused by the WorkflowParameterBindings we create to an object that has quite a few properties.
So how to fix the problem. Well we have the SQL source, so I ended up by changing the column size to 4000 characters and changing the implementation of the storedProcedures InsertAddedActivity and GetWorkflowChanges. The InstertAddedActivity has a prameter which size needs to increase to 4000 and the GetWorkflowChanges Stored Procedure uses a temporary table for returning the results. Here I needed to change that table to also match the new size of the AddedActivityAction column.
If you run into the same problem, you can download the changes SQL scripts here. I ofcourse logged the issue at connect as well(http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=302840), and hope this will be fixed in the next release of Workflow.
Cheers,
Marcel
Follow my new blog on http://fluentbytes.com