More on creating in image from a workflow

Turns out I forgot to include one of the utility functions use in my previous two blog posts at and at. The code is the GetAllActivities() function in the WorkflowUtils class.
This is the missing method:
PublicSharedFunction GetAllActivities(ByVal root As Activity) As List(Of Activity)
    Dim result AsNew List(Of Activity)
    Dim i AsInteger = 0
    Dim current As Activity
    While i < result.Count
        current = result(i)
        Dim ca As CompositeActivity = TryCast(current, CompositeActivity)
        If ca IsNotNothingThen
        i += 1
    Return result
Another thing I failed to mention and got a few questions about is how the code finds the workflow type. The serialized type is contained in the SqlTrackingWorkflowInstance, or to be more specific in the WorkflowDefinition property. This is deserialized and during the process the related assemblies will be loaded. This means these assemblies, and the correct version if they are signed, must reachable by the process. Basically this means either deploying them to the GAC or copying them to the same directory or one of the directories mentioned in the private probing path. For my example I just copied the workflow assembly to the same directory as the assembly generating the image. Nice and quick for a demo but in a real live environment not quite good enough as, in all likelihood, you will contend with multiple versions of a workflow.

Leave a Reply

Your email address will not be published. Required fields are marked *