What Was I Thinking?

Follies & Foils of .NET Development
posts - 94 , comments - 348 , trackbacks - 0

Breakpoints in XAML Activated Workflows

XAML only workflows (those are xoml files without a code attribute and code beside file), do not support debugger breakpoints.  Right clicking on the activity in the workflow and selecting insert breakpoint does (as far as I can tell) nothing.

Since XAML only workflows have no associated code and therefore no IL, it makes sense that you can't set a breakpoint, after all what exactly are you attaching the breakpoint to?

XAML only workflows are all about process orchestration and flow control, we really want to debug into the code inside of the custom activities used in the workflow.

With the out-of-the-box breakpoint functionality not available, how can we set breakpoints in our workflows?  My answer to this problem is a custom activity;  DebuggerBreakpointActivity

The activity is straightforward and comes down to a single conditional statement:


    [ToolboxBitmap(typeof(DebuggerBreakpointActivity), “DebuggerBreakpointActivity.DebuggerBreakpointActivityLogo.png")]
    [ActivityValidator(typeof (DebuggerBreakpointActivityValidator))]
    [Designer(typeof (DebuggerBreakpointActivityDesigner), typeof (IDesigner))]
    public class DebuggerBreakpointActivity : Activity
    {   

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext ctx)
        {

            try
            {
                if (System.Diagnostics.Debugger.IsAttached)
                    System.Diagnostics.Debugger.Break();
               
            }
            catch
            {
            }

            // mark this activity as closed.
            return ActivityExecutionStatus.Closed;
        }

 

When executing, the activity checks to see if the debugger is attached, if so, it programmatically inserts a breakpoint.  From here I can step through all my custom activity code and can monitor my workflow execution paths.

When not running in debug mode, the debugger is not present and the activity completes with no action taken.

A side note:  when I drag this activity onto my design surface, I set the activity name to something useful.  this way I can monitor my execution flow by simply checking the name value of the activity (which appears automatically in the locals window).

 

Print | posted on Wednesday, December 12, 2007 10:18 AM | Filed Under [ Windows Workflow Foundation ]

Feedback

Gravatar

# re: Breakpoints in XAML Activated Workflows

Hi.,


I got an error as Below.

the type or namespace name 'ActivityValidator' does not exist in the namespace (are you missing an assembly reference )
6/27/2016 11:25 AM | Dhanasekar
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: