[URGENT]Problem in EVENTHANDLING using DYNAMICALLY LOADED ASSEMBLIES!
Hi WF Gurus,
Im having a problem ineventhandling using dynamically loading assemblies. That time the value of the event is gettinNULL.
So just for checking,I tried the same in theORDERINGSTATEMACHINE Sample.There also im having the same issue that theOrderCreated event is gettin NULL value.In the sample, Instead of calling the RaiseOrderCreatedEvent method like this...
orderService.RaiseOrderCreatedEvent(orderId, workflowInstanceId);
Im calling the event by creating the services dynamically and adding it to a hashtable and making the object for the orderservice class during runtime and calling the RaiseOrderCreatedEvent Method.
Everything is working fine but the value of the OrderCreated event is getting NULL.Otherwise without loading assemblies dynamically,the event is not gettin null and its working fine.
Please help me to figure out whats happening wrong here.. For ur kind reference, im giving the code sample of what all changes i did in the sample...
privatevoid StartWorkflowRuntime()
{
workflowRuntime =
newWorkflowRuntime();workflowRuntime.WorkflowTerminated +=
newEventHandler<WorkflowTerminatedEventArgs>(WorkflowRuntime_WorkflowTerminated);workflowRuntime.WorkflowCompleted +=
newEventHandler<WorkflowCompletedEventArgs>(WorkflowRuntime_WorkflowCompleted);workflowRuntime.WorkflowIdled +=
newEventHandler<WorkflowEventArgs>(workflowRuntime_WorkflowIdled);// Add the External Data Exchange ServiceExternalDataExchangeService dataExchangeService =newExternalDataExchangeService();workflowRuntime.AddService(dataExchangeService);
HTService =
newHashtable();orderService =
newOrderService();dataExchangeService.AddService(orderService);
LoadServices();
workflowRuntime.StartRuntime();}
privatevoid LoadServices(){
SqlConnection con =newSqlConnection();con.ConnectionString =
@"Data Source=devserver;Initial Catalog=sample;User ID=sa;Password=pass";SqlCommand cmd =newSqlCommand();SqlDataReader reader;cmd.Connection = con;
cmd.CommandType =
CommandType.Text;cmd.CommandText =
"select assemblyname from orderservice";try{
if (con.State == System.Data.ConnectionState.Closed){
con.Open();
}
reader = cmd.ExecuteReader();
using (reader){
while (reader.Read()){
// Process SprocResults datareader here.assem = reader[
"assemblyname"].ToString();}}
}
finally{
// reader.Close();}
Type ServiceType;Assembly *** =Assembly.LoadFrom(assem);try{
ServiceType = ***.GetType(classnam,
true,true);objService =
Activator.CreateInstance(ServiceType);}
catch (Exception e){
MessageBox.Show(e.Message);}
if (objServiceisOrderService){
workflowRuntime.AddService(objService);
HTService[
"order"] = objService;}
}
privatevoid btnOrderCreated_Click(object sender,EventArgs e)
{
// Get the OrderId that was entered by the user
string orderId =this.txtOrderID.Text;// Start the Order WorkflowSystem.
Guid workflowInstanceId =this.StartOrderWorkflow();// Raise an OrderCreated event using the Order Local ServiceOrderService objService = (OrderService)HTService["order"];objService.RaiseOrderCreatedEvent(orderId, workflowInstanceId);
}
The RaiseOrderCreatedEvent is gettin called but theOrderCreatedevent is getting value NULL hence the event is not gettin FIRED!...
Waiting 4 ur valuable thoughts to fix this issue...
Thanks in advance
Sunath

