locked
Using ActivityAction with DelegateInArgument RRS feed

  • Question

  • Hello Guys,

    I liked to pass parameter to child activities (only know at the run time). As per advice from a expert from this forum I wrote code like this

    protected override void Execute(NativeActivityContext context) 
    { 
    RecordNumberResponse recordNumberResponse = new RecordNumberResponse(); 
    recordNumberResponse.Value = 5; //int type
    
    DelegateInArgument<RecordNumberResponse> delegateInArgument = new DelegateInArgument<RecordNumberResponse>() 
    { 
    Name = "RecordNumberResponse" 
    }; 
    activityAction = new ActivityAction<RecordNumberResponse>() 
    { 
    Argument = delegateInArgument, 
    DisplayName = Guid.NewGuid().ToString(), 
    Handler = Body //Body is a Activity Which is being passed to this custom activity as property.
    }; 
    context.ScheduleAction<RecordNumberResponse>(activityAction, recordNumberResponse, Completed); 
    } 
    
    protected override void CacheMetadata(NativeActivityMetadata metadata) 
    { 
    RuntimeArgument argument1 = new RuntimeArgument("RecordNumberResponse", typeof(RecordNumberResponse), ArgumentDirection.InOut); 
    metadata.Bind(RecordNumberResponse, argument1); metadata.AddArgument(argument1); 
    metadata.AddDelegate(activityAction); 
    }
    


    Now this is not working. So I would like to ask

    1. Is this right way to pass arguments to child activity?

    2. It's throwing a runtime error at line "context.ScheduleAction<RecordNumberResponse>(activityAction, recordNumberResponse, Completed);"

    Exception messages says "ActivityDelegate 'e3cd7f5c-0fa2-491e-b8c4-2b9e9945ad0e' should have an owner workflow element specified."

    Please advice.


    Software Engineer

    Wednesday, March 7, 2012 8:52 PM

Answers

  • You must not new the activity action inside Execute(). The activity action must be the same CLR object passed to metadata.AddDelegate().

    activityAction = new ActivityAction<RecordNumberResponse>()

    Tim

    Wednesday, March 14, 2012 6:13 AM