Avoiding “An Activity can only get the location of arguments which it owns.”

This is a follow-up question to Setting internal properties in composite WF4 Activities at design time.

I am creating a composite Windows Workflow Activity (under .NET 4) that contains Receive and SendReply Activities with some of the properties predefined. This is a NativeActivity, not an Activity Template. (See @Maurice's reply to the above question for an example.)

If I attempt to set an InArgument associated with the internal SendReply from Execute (using the parent's context), I get an InvalidOperationException:

An Activity can only get the location of arguments which it owns. Activity 'CreateInstance' is trying to get the location of argument 'Parameter0' which is owned by activity 'SendReply'.

In my case I'm trying to set a CorrelationHandle, but I believe this would affect SendParametersContent Parameters as well. How can I work around this?


Here is an update version of the CacheMetadata that stores the input argument in a variable and uses it in the response and sets the CorrelationHandle. The basic trick is to add the them as Variable using the AddImplementationVariable, because the activities are added using AddImplementationChild.

protected override void CacheMetadata(NativeActivityMetadata metadata)
    _receive = _receive ?? new Receive();
    _sendReply = _sendReply ?? new SendReply();
    _receive.CanCreateInstance = true;

    _receive.ServiceContractName = ServiceContractName;
    _receive.OperationName = OperationName;

    var correlationHandle = new Variable<CorrelationHandle>("correlationHandle");
    var correlationInitializer = new RequestReplyCorrelationInitializer()
        CorrelationHandle = new InArgument<CorrelationHandle>(correlationHandle)

    var firstName = new Variable<string>("firstName");
    var args = new ReceiveParametersContent();
    args.Parameters["firstName"] = new OutArgument<string>(firstName);
    _receive.Content = args;

    _sendReply.Request = _receive;
    var results = new SendParametersContent();
    results.Parameters["greeting"] = new InArgument<string>(new VisualBasicValue<string>("\"Hello \" & firstName"));
    _sendReply.Content = results;


Need Your Help

Git: Patching changes made in a unrelated repo

git merge diff patch

Let me explain the problem with a example:

Do you need an Interface by RESTful webservice?

web-services rest interface

I'm busing to build a simple RESTful webservice for my thesis, maybe this is a dome quetion but I just want to know, do you really need an interface (WADL or WSDL) to create clients? Likely by SOAP

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.