Cannot create more than one WorkflowRuntime per AppDomain
I want to use workflow in 2 asp.net pages. This is how i am doing.
In first page i it will update one status and in second page it will update 2 nd status.
I am using the follwoing architecture
ASP.net page -- > Business Layer-- Windows Workflow - Dataaccess Layer
ASP.net PAge:
-
In this page first it has to run workflow then update database.
protected void btnSave_Click(Object sender, EventArgs e)
{
_businesslayer = new BusinessLayer.NewAccWorkFlow();
_businesslayer.Update("Analyst","Review");
}
Business LAyer:
-
namespace BusinessLayer
{
public class NewAccWorkFlow
{
WorkflowRuntime wf;
private void Update Status(string inputType, string status)
{
Dictionary<string, object> parms = new Dictionary<string, object>();
parms.Add("Type", inputType);
parms.Add("Status", status);
wf = new WorkflowRuntime();
WorkflowInstance wfInstance = wf.StartWorkflow(type, parms);
id = wfInstance.InstanceId;
}
}
}
Probem here is:
First time when you save page its executing well. When you save first time its creating instance of workflow and executing well. But the user can save different data again on the same page. When you do that its trying to create another instance
which is already in app domain. In both pages i am going to call Update methos in Business Layer.
Is this the better way to do?
Could you suggest the way that i can use my work flow in multiple pages (where exactly i have to instantiate and use in multiple pages.)
I really appriciate for your help
Thanks
Sridhar

