Windows Workflow: Use of ConditionedActivityGroup activity

One of our developers used ConditionedActivityGroup activity with a single branch.
ConditionedActivityGroup is a kind do of loop, but it should not be used instead of the WhileActivity.
There are a few reasons for this:
1.Use the simplest tool that satisfy your requirement
2.workflow designer doesn’t expand body of ConditionedActivityGroup, and you need to click it to Preview
3. If you have many activities in the workflow, the designer becomes terribly slow(VS 2008)
The huge workflows should be considered for refactoring by converting parts of workflow into custom composite activity or as separate worklow (with InvokeWorkflow activity)
I have a question,  should I use Code Conditions vs Rule Conditions?
The article Windows Workflow: Rules and Conditions describes these types of conditions.
Conditional Activities in Windows Workflow Foundation talks about Advantages of using Rule Conditions:


  • Rule conditions are included in the declarative model and can be dynamically updated at run-time
  • The .rules file provides code separation and enables external analysis /tools to be built on top of the .rules file.  
Also to set the conditions declaravely via Rules  simpler for new Activity.
However if you are using code-behind for the workflow, specify code conditions is more consistent and easy to maintain/investigate.
Editing declarative conditions in Workflow Designer is too slow.
Also VS “find references”  could NOT see the references from rule conditions, which make development harder.

Windows Workflow: Concatenate all parents QualifiedNames- instead of call stack

MSDN Debugging Workflows  tells that

The entries in the Call Stack window are a depth-first search of executing activities. You can double-click an entry to put focus on the selected activity.-It doesn’t work for me.

 The text on stack trace is not meaningful, when activities are described.

 > codeRaiseEvent_ExecuteCode(object sender = {codeRaiseEvent_CAGPNRIterate [System.Workflow.Activities.CodeActivity]}, System.EventArgs e = {System.EventArgs}) Line 671 C#
  System.Workflow.ComponentModel.dll!System.Workflow.ComponentModel.Activity.RaiseEvent(System.Workflow.ComponentModel.DependencyProperty dependencyEvent, object sender = {codeRaiseEvent_CAGPNRIterate [System.Workflow.Activities.CodeActivity]}, System.EventArgs e = {System.EventArgs}) + 0xb0 bytes 
  System.Workflow.Activities.dll!System.Workflow.Activities.CodeActivity.Execute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext) + 0x35 bytes 
  System.Workflow.ComponentModel.dll!System.Workflow.ComponentModel.ActivityExecutor<System.__Canon>.Execute(System.__Canon activity, System.Workflow.ComponentModel.ActivityExecutionContext executionContext) + 0x2b bytes 
  System.Workflow.ComponentModel.dll!System.Workflow.ComponentModel.ActivityExecutor<System.__Canon>.Execute(System.Workflow.ComponentModel.Activity activity, System.Workflow.ComponentModel.ActivityExecutionContext executionContext) + 0x32 bytes 
  System.Workflow.ComponentModel.dll!System.Workflow.ComponentModel.ActivityExecutorOperation.Run(System.Workflow.ComponentModel.IWorkflowCoreRuntime workflowCoreRuntime) + 0xbe bytes 

I’ve created a function, that can be called to output trace in case of exception”

/// <summary>/// Concatenate all parents QualifiedNames
/// </summary> 
/// <param name=”activity”></param> 
public static string FullQualifiedName(this Activity activity)
Activity act=activity;
List<string> list = new List<string>();
while (act != null)
return CollectionsHelper.ToString<string>(list, “.”,“”);



Unrelated note that  to debug the workflow using F5 you MUST set the workflow DLL project as the Visual Studio solution startup project.


Developers should avoid smart-quotes in Word

We had a Word document, describing steps, based on MSDN instructions Use the Windows Workflow Tracking Service
I desided to create batch file createWorkflowTrackingDB.bat to create Database:

@echo Change name of Database server if required
@echo press control-Z to stop batch
sqlcmd -S localhost -E -Q “create database WorkflowTracking”
cd “C:WINDOWSMicrosoft.NETFrameworkv3.0Windows Workflow FoundationSQLEN”
sqlcmd -S localhost -E -d WorkflowTracking -i Tracking_Schema.sql
sqlcmd -S localhost -E -d WorkflowTracking -i Tracking_Logic.sql
@echo Ensure that application account has tracking_reader and tracking_writer roles

But it was failing on the line
     sqlcmd -S localhost -E -Q “create database WorkflowTracking”.
It took me a while to recognize, that MS Word replaced double-quotes with smart-quotes , and sqlcmd didn’t like it.

View Windows Workflow Tracked Data Tools

For some reasons, it took me a few google search attempts to find the following tools:

 MSDN includes  Workflow Monitor Sample -Windows executable to view details of tracked workflows.

When downloaded, copy EXE to your bin directory when custom workflow DLLs are located.
Ensure that tracking database doesn’t have too many instances, to avoid timeouts.


Jon Flanders put together the ASP.NET implementation of the Workflow Monitor SDK sample. 

 MSDN Tracking Samples mostly described how to store tracking data, but  ConsoleTrackingService Sample shows how to write the contents of tracked data to the console.
It is good for debugging, getting trace in Output window, but the records in the sample are too wordy. The similar class in Pro WF: Windows Workflow in .NET 3.5 is more brief- output one line per event. The issue with showing time of event in UTC can be fixed by calling  the method

        //the logged dateTimes are in UTC

        private DateTime GetDateInRequiredTimeZone(DateTime utcDate)


            //TODO: if required, leave in UTC or change as configurable

            return utcDate.ToLocalTime();


For configurartion tracking service see the answer in the thread Custom Tracking service in app.config, Web.config web service workflow

Related MSDN articles:Windows Workflow Foundation: Tracking Services Introduction“, Windows Workflow Foundation: Tracking Services Deep Dive

Store custom objects configuration in separate custom configuration files

We are going to have a windows service that will run a few workflow(WF) instances. I want to have configuration information to be stored in  separate config files for each WF instance.

I remembered that EntLib has helper classes to store custom objects configuration in separate custom configuration file, but finding good examples in Google wasn’t easy(probably I didn’t find good search keywords).

The links that I finally found(more relevant to the task first)

Tom Hollander ‘post External configuration files in Enterprise Library for .NET Framework 2.0 mostly talks about EntLib provider config sections, but comments are talking about FileConfigurationSource  and custom sections.

Alois Kraus has good articles in his blog : Read/Write App.config with .NET 2.0/Enterprise Library  (and similar in  CodeProject) and Microsoft Enterprise Library for .NET 2.0: Configuration .

Using section handlers to group settings in the configuration file.  shows how to use sections of the types:

  • NameValueSectionHandler
  • DictionarySectionHandler
  • SingleTagSectionHandler 


    Example of separate custom config file Enterprise Library – Configuration Application Block – Patterns and Practices is obsolete(using EntLib 1.0). See Enterprise Library 2.0 – From Configuration Block to IConfigurationSource – SystemConfigurationSource – FileConfigurationSource


    reference: Microsoft.Practices.EnterpriseLibrary.Common.Configuration Namespace

    Alternative implementations from CodeProject without using EntLib are Custom app.config  and A custom configuration file AppSettings reader class


    If you want to add  EntLib Configuration Manager Design time support for editing your sections, look at 

    Enterprise Library Configuration (Part 1/2): Customized Appsettings and the EntLib Configuration Manager tool

    Enterprise Library Configuration (Part 2/2): Customizable configuration with framework extensions  

    Alex Homer: Adding Configuration Support for Custom Providers in Enterprise Library in ASP.NET 2.

    and Enterprise Library 2.0: Building Named Extensions in the Configuration Console

  • Is it possible to convert Workflow to Custom composite activity?

    I am reading about Windows Workflow and have a question:

    If I created a workflow with a few activities (While,If etc) and want to convert it to custom composite activity with ability to insert new activities inside blocks, how can I do it?
    Analogy in ASP.NET is strightforward- just a few steps(see How to: Convert Web Forms Pages into ASP.NET User Controls ) .

    Is something similar available for WF?

    Related links how to write Custom activities:
    Creating a Custom Composite Activity – Morgan Skinner’s  article on MSDN

    MSDN documentation Concepts:  Creating Custom Composite Activities
    How to Write a Custom Workflow Activity  ,How to Write a Designer Component for Custom Workflow Activity

    A few links in OdeToCode blog: Windows Workflow Foundation and Domain Specific Languages