views:

37

answers:

1

Hi Guys,

This simple code fails with the following error:

The following errors were encountered while processing the workflow tree:

'ArgumentValue': The argument named 'Parameter' could not be found on the activity owning these private children. ArgumentReference and ArgumentValue should only be used in the body of an Activity definition.

I also tried VisualBasivValue("Parameter") instead of ArgumentValue, and the error was:

The following errors were encountered while processing the workflow tree:

'VisualBasicValue': Compiler error(s) encountered processing expression "Parameter". 'Parameter' is not declared. It may be inaccessible due to its protection level.

How to do it properly?

I tried to build something similar in Xaml, and it works, here is the code:

<Assign sap:VirtualizedContainerService.HintSize="242,58">
    <Assign.To>
        <OutArgument x:TypeArguments="x:String">[variable]</OutArgument>
    </Assign.To>
    <Assign.Value>
        <InArgument x:TypeArguments="x:String">[Parameter]</InArgument>
    </Assign.Value>
</Assign>

Looks like it references the parameter somehow, but how...

How can I do it in code? Here is my simple scenario:

public class RootActivity : NativeActivity
{
    public InArgument<string> Parameter { get; set; }

    public Activity Activity { get; set; }

    public RootActivity()
    {
        var variable = new Variable<string>("V1", "This is my variable!");
        var activity = new Sequence
            {
                Variables = {variable},
                Activities =
                {
                    new Assign<string>
                    {
                        To = new OutArgument<string>(variable),
                        Value = new InArgument<string>(
                            new ArgumentValue<string>("Parameter"));
                    },
                }
            };

        this.Activity = activity;
    }

    protected override void Execute(NativeActivityContext context)
    {
        context.ScheduleActivity(this.Activity);
    }
}

Thanks a lot for any help!

A: 

I'm not exactly sure, but there is one thing I've noticed.

I've found that trying to configure an activity within a constructor often does not work. It is advisable to do this within the Create method of IActivityTemplateFactory.

Change your code so that you implement this method, then move the code from the constructor to the Create method. This may not be your whole issue, but it could be one of them.

Will