What Was I Thinking?

Follies & Foils of .NET Development

  Home  |   Contact  |   Syndication    |   Login
  28 Posts | 0 Stories | 58 Comments | 0 Trackbacks

News

Archives

Post Categories

Check These Out

Gurus

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).

 

posted on Wednesday, December 12, 2007 10:18 AM

Feedback

# re: Breakpoints in XAML Activated Workflows 12/2/2008 9:19 PM Harry
You can easily add break point in your XOML, it's working as intended, you can even step inside the code if you want...using F11.

Not sure why you need this.....

Post Feedback

Title:
Name:
Email: (never displayed)
Url:
Comments: 
Please add 6 and 3 and type the answer here: