Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6746513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:19:54+00:00 2026-05-26T12:19:54+00:00

I am building custom activities, First activity is containing ReceiveSendReply activity with some other

  • 0

I am building custom activities, First activity is containing ReceiveSendReply activity with some other activities. In this activity I am creating workflow instance. I want to assign a Intialized CorrelationHandle to the OutArgument. Which will be assigned to the outer shared varriable.

In another activity I have another ReceiveSendReply activity, which will resume the instance created by the above said activity. In second activity I have CorrelationHandle as InArgument. I will assign this InArgument with the outer shared correlationHandle varriable.

When I am executing this workflow service, first operation executes without any issue and it populate the correlation key and I am receiving that correlation key in the response. When I am executing the second activity using the received correlation key, service return with the following exception:

“The execution of an InstancePersistenceCommand was interrupted because the instance key ’45f99690-2829-3126-0782-99033212633c’ was not associated to an instance. This can occur because the instance or key has been cleaned up, or because the key is invalid. The key may be invalid if the message it was generated from was sent at the wrong time or contained incorrect correlation data.”

I want to know how to share a CorrelationHandle between two custom activities by using OutArgument and InArguments?

public sealed class Create : Activity
{
    public Create()
    {
        Implementation = new Func<Activity>(CreateBody);
    }

    public string ServiceContract { get; set; }

    public string Operation { get; set; }

    [RequiredArgument]
    public OutArgument<CorrelationHandle> CorrelationHandle { get; set; }

    Activity CreateBody()
    {
        // variables declaration. 
        var requestContent = new Variable<string>();
        var operationResponseParam = new Variable<OperationResponseParam>();
        var correlationKey = new Variable<string>();
        var correlationHandle = new Variable<CorrelationHandle>();

        Receive receiveRequest;

        return new Sequence
        {
            Variables = { correlationHandle, correlationKey }, 
            Activities = 
            {
                {receiveRequest = new Receive()
                {
                    ServiceContractName = ServiceContract,
                    OperationName = Operation,
                    CanCreateInstance = true,
                    Content = new ReceiveMessageContent
                    {
                        Message = new OutArgument<string>(ctx => operationRequestParam.Get(ctx))
                    },
                }},

                new Assign<string>
                {
                    To = new OutArgument<string>(ctx => correlationKey.Get(ctx)),
                    Value = new InArgument<string>(ctx => Guid.NewGuid().ToString())
                },

                new Assign<ApplicationDataList>
                {
                    To = new ArgumentReference<ApplicationDataList>("AppData"),
                    Value = new InArgument<ApplicationDataList>(ctx =>appData.Get(ctx))
                },

                new Assign<OperationResponseParam>
                {
                    To = new OutArgument<OperationResponseParam>(ctx => operationResponseParam.Get(ctx)),
                    Value = new InArgument<OperationResponseParam>
                    {
                        Expression = new BuildResponse()
                        {
                            CorrelationKey = new InArgument<string>(correlationKey),
                        }
                    }
                },

                new SendReply
                {
                    Request = receiveRequest,
                    Content = new SendMessageContent
                    {
                        Message = new InArgument<OperationResponseParam>(ctx => operationResponseParam.Get(ctx))
                    },

                    CorrelationInitializers =
                    {
                        new QueryCorrelationInitializer
                        {
                            CorrelationHandle =  new InArgument<CorrelationHandle>(correlationHandle),
                            MessageQuerySet = new MessageQuerySet
                            {
                                {
                                    "CorrelationKey", new XPathMessageQuery("sm:header()/tempuri:CorrelationKey")
                                }
                            }
                        }
                    }
                },

                new Assign<CorrelationHandle>
                {
                    To = new ArgumentReference<CorrelationHandle>("CorrelationHandle"),
                    Value = new InArgument<CorrelationHandle>(ctx =>correlationHandle.Get(ctx))
                },
            }
        };
    }
}


public sealed class Wait : Activity
{
    public Wait()
    {
        Implementation = new Func<Activity>(CreateBody);
    }

    public string ServiceContract { get; set; }

    public string Operation { get; set; }

    [RequiredArgument]
    public InArgument<CorrelationHandle> CorrelationHandle { get; set; }

    Activity CreateBody()
    {
        // variables declaration. 

        var operationRequestParam = new Variable<OperationRequestParam>();
        var operationResponseParam = new Variable<OperationResponseParam>();
        var correlationHandle = new Variable<CorrelationHandle>();
        Receive receiveRequest;

        return new Sequence
        {
            Variables = { correlationHandle },
            Activities =
            {
                new Sequence
                {
                    Variables = {operationRequestParam, operationResponseParam },

                    Activities = 
                    {
                        {receiveRequest =new Receive()
                        {
                            ServiceContractName = ServiceContract,
                            OperationName = Operation,
                            CanCreateInstance = false,
                            CorrelatesWith = new InArgument<CorrelationHandle>(ctx => CorrelationHandle.Get(ctx)),
                            CorrelatesOn = new MessageQuerySet
                            {
                                { "CorrelationKey", new XPathMessageQuery("sm:header()/tempuri:CorrelationKey")}
                            },

                            //parameters for receive
                            Content = new ReceiveMessageContent
                            {
                                Message = new OutArgument<OperationRequestParam>(ctx => operationRequestParam.Get(ctx))
                            },
                        }},


                        new Assign<OperationResponseParam>
                        {
                            To = new OutArgument<OperationResponseParam>(operationResponseParam),
                            Value = new InArgument<OperationResponseParam>
                            {
                                Expression = new BuildResponse()
                                {
                                    ApplicationData = new InArgument<ApplicationDataList>(ctx => appData.Get(ctx)),
                                }
                            }
                        },

                        new SendReply
                        {
                            Request = receiveRequest,
                            Content = new SendMessageContent
                            {
                                Message = new InArgument<OperationResponseParam>(ctx => operationResponseParam.Get(ctx))
                            }
                        },
                    }
                },
            }
        };
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:19:55+00:00Added an answer on May 26, 2026 at 12:19 pm

    We should use the handle as an InArgument, and the object refereing the handle will be modified by InitializeCorrelation. So in my both activities I have to use InArgument instead of OutArgument in the first and InArgument in the second.

    public sealed class Create : Activity
    {
        public Create()
        {
            Implementation = new Func<Activity>(CreateBody);
        }
    
        public string ServiceContract { get; set; }
    
        public string Operation { get; set; }
    
        [RequiredArgument]
        public InArgument<CorrelationHandle> CorrelationHandle { get; set; }
    
        Activity CreateBody()
        {
            // variables declaration. 
            var operationRequestParam = new Variable<OperationRequestParam>();
            var appData = new Variable<ApplicationDataList>();
            var operationResponseParam = new Variable<OperationResponseParam>();
            var correlationKey = new Variable<string>();
    
    
            Receive receiveRequest;
    
            return new Sequence
            {
                Variables = { correlationKey }, 
                Activities = 
                {
                    {receiveRequest = new Receive()
                    {
                        ServiceContractName = ServiceContract,
                        OperationName = Operation,
                        CanCreateInstance = true,
                        //parameters for receive
                        Content = new ReceiveMessageContent
                        {
                            Message = new OutArgument<string>(ctx => operationRequestParam.Get(ctx))
                        },
                    }},
    
                    // Assign a unique identifier to the correlation key.
                    new Assign<string>
                    {
                        To = new OutArgument<string>(ctx => correlationKey.Get(ctx)),
                        Value = new InArgument<string>(ctx => Guid.NewGuid().ToString())
                    },
    
                    new Assign<OperationResponseParam>
                    {
                        To = new OutArgument<OperationResponseParam>(ctx => operationResponseParam.Get(ctx)),
                        Value = new InArgument<OperationResponseParam>
                        {
                            Expression = new BuildResponse()
                            {
                                CorrelationKey = new InArgument<string>(correlationKey),
                            }
                        }
                    },
    
                    new SendReply
                    {
                        Request = receiveRequest,
                        Content = new SendMessageContent
                        {
                            Message = new InArgument<string>(ctx => operationResponseParam.Get(ctx))
                        },
    
                        CorrelationInitializers =
                        {
                            new QueryCorrelationInitializer
                            {
                                CorrelationHandle =  new InArgument<CorrelationHandle>(ctx => CorrelationHandle.Get(ctx)),
                                MessageQuerySet = new MessageQuerySet
                                {
                                    {
                                        "CorrelationKey", new XPathMessageQuery("sm:header()/tempuri:CorrelationKey")
                                    }
                                }
                            }
                        }
                    },
                }
            };
        }
    }
    
    public sealed class Wait : Activity
    {
        static Wait()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();
            builder.AddCustomAttributes(typeof(Wait), "EscalationData", new EditorAttribute(typeof(EscalationDataEditor), typeof(DialogPropertyValueEditor)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
    
        public Wait()
        {
            Implementation = new Func<Activity>(CreateBody);
        }
    
        public EscalationInfoList EscalationData { get; set; }
    
        public string ServiceContract { get; set; }
    
        public string Operation { get; set; }
    
        [RequiredArgument]
        public InArgument<CorrelationHandle> CorrelationHandle { get; set; }
    
        Activity CreateBody()
        {
            // variables declaration. 
            var appData = new Variable<ApplicationDataList>();
            var operationRequestParam = new Variable<OperationRequestParam>();
            var operationResponseParam = new Variable<OperationResponseParam>();
    
            Receive receiveRequest;
    
            return new Sequence
            {
                Activities =
                {
                   new Sequence
                   {
                        Variables = {operationRequestParam, operationResponseParam },
    
                        Activities = 
                        {
                            {receiveRequest =new Receive()
                            {
                                ServiceContractName = ServiceContract,
                                OperationName = Operation,
                                CanCreateInstance = false,
                                CorrelatesWith = new InArgument<CorrelationHandle>(ctx => CorrelationHandle.Get(ctx)),
                                CorrelatesOn = new MessageQuerySet
                                {
                                    { "CorrelationKey", new XPathMessageQuery("sm:header()/tempuri:CorrelationKey")}
                                },
    
                                //parameters for receive
                                Content = new ReceiveMessageContent
                                {
                                    Message = new OutArgument<OperationRequestParam>(ctx => operationRequestParam.Get(ctx))
                                },
                            }},
    
                            new SendReply
                            {
                                Request = receiveRequest,
                                Content = new SendMessageContent
                                {
                                    Message = new InArgument<OperationResponseParam>(ctx => operationResponseParam.Get(ctx))
                                }
                            },
                        }
                    },
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a custom Sharepoint 2010 activity which does some business logic, and at
I'm building some custom tools to work against a JIRA install, and the exposed
I'm building a custom UITableView with each of the cells containing a piece of
I'm building a custom ItemsControl in Silverlight that (amongst other things) allows items to
I'm building custom content filtering system using custom radio buttons. There are some problems
I am building a custom rpm to install apache, among other things. When i
I am building a custom ProgressDialog and would like for the background Activity to
I'm building a custom web control with a public property which I only want
I am trying to find some examples of building a custom model binder for
Im building a custom generator for my app where I basically want to wrap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.