locked
Argument Bug Illustrated RRS feed

  • Question

  • Good morning all,

    I have a fairly straightforward workflow that downloads files from a ftp server as part of it's normal operation.  Unfortunately Arguments seem to be problematic.   I declare and initialize a string argument named DownloadRoot, the designer likes it and allows it's use in expressions.   During the setup for a debug session I call the SourceLocationProvider.CollectMappings(...) which throws the exception show below.  However at runtime the workflow works exactly as intended.  This seems to be a bug in SourceLocationProvider.


    Monday, September 26, 2011 10:46 AM

Answers

  • Hi Tim,

    I should have posted a followup to this, I've been a tad busy.

    The issue actually isn't in SourceLocationProvider.  The issue was in how I was getting the root runtime activity to pass to SourceLocationProvider.

    My original code looked similar to this:

     private Activity GetRootRuntimeWorkFlowElement()
            {
                Activity root = GetRuntimeExecutionRoot();
    
                IEnumerator<Activity> activityenum = WorkflowInspectionServices.GetActivities(root).GetEnumerator();
                activityenum.MoveNext()
                root = activityenum.Current;
                return root;
            }
    


    This works, right up until the point where you have arguments with default values.  The default values are set using activities that run before the workflowroot...  I had to change the above code to skip over these initializers.

            private Activity GetRootRuntimeWorkFlowElement()
            {
                Activity root = GetRuntimeExecutionRoot();
    
                IEnumerator<Activity> activityenum = WorkflowInspectionServices.GetActivities(root).GetEnumerator();
                while(activityenum.MoveNext())
                {
                    root = activityenum.Current;
                    //We have to skip the arugments which will be either in the expression namespace (for scalar literals)
                    //or in the Activities namespace (for complex types)
                    var actnamespace = root.GetType().Namespace;
                    if (actnamespace == "System.Activities.Statements")
                        return root;
                }
                //This should never be hit...but if it is the caller will throw an invalid workflow exception
                return null;
            }
    
    

    Once I made this change the code returned to working as expected :D

    Thursday, September 29, 2011 8:59 PM

All replies

  • Hi Frank,
    That does look odd. If you have the time would you mind filing the repro on https://connect.microsoft.com/wf so the team can look at it for VS vNext?
    Tim

    Wednesday, September 28, 2011 10:12 PM
  • Hi Tim,

    I should have posted a followup to this, I've been a tad busy.

    The issue actually isn't in SourceLocationProvider.  The issue was in how I was getting the root runtime activity to pass to SourceLocationProvider.

    My original code looked similar to this:

     private Activity GetRootRuntimeWorkFlowElement()
            {
                Activity root = GetRuntimeExecutionRoot();
    
                IEnumerator<Activity> activityenum = WorkflowInspectionServices.GetActivities(root).GetEnumerator();
                activityenum.MoveNext()
                root = activityenum.Current;
                return root;
            }
    


    This works, right up until the point where you have arguments with default values.  The default values are set using activities that run before the workflowroot...  I had to change the above code to skip over these initializers.

            private Activity GetRootRuntimeWorkFlowElement()
            {
                Activity root = GetRuntimeExecutionRoot();
    
                IEnumerator<Activity> activityenum = WorkflowInspectionServices.GetActivities(root).GetEnumerator();
                while(activityenum.MoveNext())
                {
                    root = activityenum.Current;
                    //We have to skip the arugments which will be either in the expression namespace (for scalar literals)
                    //or in the Activities namespace (for complex types)
                    var actnamespace = root.GetType().Namespace;
                    if (actnamespace == "System.Activities.Statements")
                        return root;
                }
                //This should never be hit...but if it is the caller will throw an invalid workflow exception
                return null;
            }
    
    

    Once I made this change the code returned to working as expected :D

    Thursday, September 29, 2011 8:59 PM