locked
WorkflowApplication.Load using SqlWorkflowInstanceStore has issues with parameters RRS feed

  • Question

  • Hello Everyone,

    I am passing parameters while invoking the workflow using a Dictionary object. I have no issues when the workflow is invoked for the first time as the instance of the workflow is stored in the database and the parameter values are read into the workflow. when I invoke the workflow using the GUID that was saved in the database by passing parameters to the workflowapplication class, I get a InvalidOperationException "Workflow inputs cannot be used with Load(), since they are only provided to new instances". Any help is greatly appreciated. I am using WF 4.0 in Beta 2. Following is a code snippet for the Load.

    Thanks,
    Kiran

    using (AutoResetEvent syncEvent = new AutoResetEvent(false))
                {
                    SqlWorkflowInstanceStore sqlInstanceStore = new SqlWorkflowInstanceStore();
                    sqlInstanceStore.ConnectionString = "Data Source=.;Initial Catalog=SQLStore; Integrated Security=True";
    
                    InstanceView view = sqlInstanceStore.Execute(sqlInstanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
    
                    sqlInstanceStore.DefaultInstanceOwner = view.InstanceOwner;
    
                    IDictionary<string, object> requestorData = new Dictionary<string, object>();
    
                    requestorData.Add("PersonName", "");
                    requestorData.Add("Qualification", "");
                    requestorData.Add("Experience", "");
                    requestorData.Add("Comments", Comments);
    
                    WorkflowApplication app = new WorkflowApplication(new HiringRequest.HiringActivity(), requestorData);
    
                    app.PersistableIdle = e =>
                    {
                        return PersistableIdleAction.Unload;
                    };
    
                    app.Unloaded = e =>
                    {
                        syncEvent.Set();
                    };
    
                    app.InstanceStore = sqlInstanceStore;
    
                    app.Load(new Guid("E7626C78-86AD-4D94-A7A2-BE3A54542D96"));
    
                    app.Run();
    
                    BookmarkResumptionResult RequestorResult = app.ResumeBookmark("RequestorMark", null);
    
                    syncEvent.WaitOne();
    
                    app.Unload();
                    
                }
    Saturday, January 30, 2010 12:35 PM

Answers

  • I wonder if I'm understanding the scenario you are working within. It sounds like you want to pass new data to your workflow when you rehydrate it. If you created the bookmark, and the bookmark routine, you can pass extra data when resuming the bookmark.

     app.ResumeBookmark("RequestorMark", dataToPass);

    (This is different from the arguments which you pass in to the workflow instance when it is first created.)

    Tim
    • Marked as answer by Kiran Bondili Sunday, January 31, 2010 3:38 PM
    Sunday, January 31, 2010 4:52 AM

All replies

  • The way I understand the error message is that you should only pass requestorData into WorkflowApplication() constructor the first time you run it.

    On later resumes of the workflow, the arguments should be retrieved from the serialized instance data.

    WorkflowApplication app = new WorkflowApplication(new HiringRequest.HiringActivity());

    Tim
    Sunday, January 31, 2010 2:12 AM
  • Hello Tim,

    How can I pass values to the workflow when I invoke the workflow using workflowapplication class with the load event using the guid which is stored after the first run.

    Kiran



    Sunday, January 31, 2010 4:09 AM
  • I wonder if I'm understanding the scenario you are working within. It sounds like you want to pass new data to your workflow when you rehydrate it. If you created the bookmark, and the bookmark routine, you can pass extra data when resuming the bookmark.

     app.ResumeBookmark("RequestorMark", dataToPass);

    (This is different from the arguments which you pass in to the workflow instance when it is first created.)

    Tim
    • Marked as answer by Kiran Bondili Sunday, January 31, 2010 3:38 PM
    Sunday, January 31, 2010 4:52 AM
  • I tried your suggestion and it worked for me.
    I am able to pass values to variables inside the workflow from the parameters of ResumeBookmark. Thanks for helping me out.

    Kiran
    Sunday, January 31, 2010 3:38 PM