locked
Debug coded WorkflowServiceHost RRS feed

  • Question

  • Is it possible to debug a coded Windows Workflow .Net 4.0.1 self-hosted WorkflowServiceHost? I have

    <system.web>
     
    <compilation debug="true" />
    </system.web>

    set in the app.config file. However, whenever I set a break point, the debugger stops at the point when the WorkflowServiceHost object is being constructed and not when an individual workflow instance reaches the break point.

    By "coded" I mean the workflow is specified in C# instead of in the visual designer.

    Thursday, July 5, 2012 7:48 PM

Answers

  • Hi,

    You can create a custom code activity to inspect the value of scoped variables, the code looke like:

        public sealed class CodeActivity1 : CodeActivity
        {
            // Define an activity input argument of type string
            //public InArgument<string> Text { get; set; }
    
            // If your activity returns a value, derive from CodeActivity<TResult>
            // and return the value from the Execute method.
            protected override void Execute(CodeActivityContext context)
            {
                // Obtain the runtime value of the Text input argument
                //string text = context.GetValue(this.Text);
               PropertyDescriptorCollection collection=  context.DataContext.GetProperties();
               foreach (PropertyDescriptor des in collection)
               {
                   Console.WriteLine(des.DisplayName+ " : " + des.GetValue(context.DataContext).ToString());
               }
            }
        }

    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Ben112358 Tuesday, July 10, 2012 2:46 PM
    Tuesday, July 10, 2012 5:11 AM

All replies

  • Hi,

    Base on your description, you created workflow definition programmatically via C#. As the code executes as part of the creation of the workflow definition,  it reaches the break point when the workflowServiceHost object is being constructed. If you want to debug the execution of an individual workflow instance, then you need to set break point on the code which executes as part of the execution of an instance of that workflow. Thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, July 9, 2012 1:57 AM
  • Thanks. So it seems like it's not possible to inspect the value of a Workflow's Variable<>'s then (unless they are passed explicitly to a method external to the definition) 
    Variable<int> var = new Variable<int>();
    ...
    ExpressionServices.Convert( e => Some.Method( var.Get(e) ));

    Is there a way to access the collection of all scoped variables from within a StateMachine State? I could then pass this collection to a method and set a breakpoint inside the method. 
    • Edited by Ben112358 Monday, July 9, 2012 2:22 PM
    Monday, July 9, 2012 1:41 PM
  • Hi,

    You can create a custom code activity to inspect the value of scoped variables, the code looke like:

        public sealed class CodeActivity1 : CodeActivity
        {
            // Define an activity input argument of type string
            //public InArgument<string> Text { get; set; }
    
            // If your activity returns a value, derive from CodeActivity<TResult>
            // and return the value from the Execute method.
            protected override void Execute(CodeActivityContext context)
            {
                // Obtain the runtime value of the Text input argument
                //string text = context.GetValue(this.Text);
               PropertyDescriptorCollection collection=  context.DataContext.GetProperties();
               foreach (PropertyDescriptor des in collection)
               {
                   Console.WriteLine(des.DisplayName+ " : " + des.GetValue(context.DataContext).ToString());
               }
            }
        }

    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Ben112358 Tuesday, July 10, 2012 2:46 PM
    Tuesday, July 10, 2012 5:11 AM