0
shyamjith created
Hi
I am trying to add a list of hangfire recurring jobs by iterating a list but I am getting an exception when running this code.
"An exception of type 'System.Transactions.TransactionManagerCommunicationException' occurred in System.Transactions.dll but was not handled in user code"
"Additional information: Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool."
Here I am attacting my code
foreach(var item in schedulerModel)
{
if(item!=null)
{
RecurringJob.RemoveIfExists(item.SchedulerName);
string jobInterval = "";
if(item.SchedulerIntervalId==(int)Enums.SchedulerInterval.Hourly)
{
jobInterval = Cron.Hourly(item.ScheduledHour);
}
else
{
jobInterval = Cron.Daily(item.ScheduledHour,item.ScheduledMinute);
}
//Type thisType = this.GetType();
//MethodInfo theMethod = thisType.GetMethod(item.MethodName);
//MethodInfo method = typeof(IBackGroundJobManager).GetMethod(item.MethodName);
//RecurringJob.AddOrUpdate(item.SchedulerName,() => method.Invoke(this, null), jobInterval);
switch(item.SchedulerName)
{
case "Job1":
RecurringJob.AddOrUpdate<IBackGroundJobManager>(item.SchedulerName, t =>t.Job1(), jobInterval);
break;
case "Job2":
RecurringJob.AddOrUpdate<IBackGroundJobManager>(item.SchedulerName, t => t.Job2(), jobInterval);
break;
case "Job3":
RecurringJob.AddOrUpdate<IBackGroundJobManager>(item.SchedulerName, t => t.job3(), jobInterval);
break;
case "job4":
RecurringJob.AddOrUpdate<IBackGroundJobManager>(item.SchedulerName, t => t.job4(), jobInterval);
break;
case "job5":
RecurringJob.AddOrUpdate<IBackGroundJobManager>(item.SchedulerName, t => t.job5(), jobInterval);
break;
}
}
}
1 Answer(s)
-
0
Hi,
If you are accessing a different database, MSDTC windows service must be running on your machine. If your database and web server are different, you need to run it on both servers.