I’m getting this error some times… after start the job, it changes to schedule with the error below.
Sometimes the job runs sucessfully so I notice that if I start the same job 3 times, one of them finish and others goes to schedule with the error.
I set the startup (It’s called after inject all dependencies.):
public class Startup
{
public void Configuration(IAppBuilder app)
{
var options = new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = false,
SchemaName = "dbo"
};
GlobalConfiguration.Configuration
.UseSqlServerStorage(Connection.GetConnectionString("MyDataBase"), options);
// .UseMsmqQueues(@".\hangfire-{0}");
GlobalConfiguration.Configuration
.UseActivator(new SimpleInjectorJobActivator(MvcApplication.container));
// Hangfire Dashboard UI
// Map Dashboard to the `http://<your-app>/hangfire URL.
app.UseHangfireDashboard("/jobs");
//#if (!DEBUG)
// Hangfire Server
app.UseHangfireServer();
// Init recurring tasks
var jobs = MvcApplication.container.GetInstance<ISetupJob>();
jobs.Configure();
//#endif
}
}
This is the job:
public class JobCalculateBalance
{
private readonly INotificationBusiness notificationBusiness;
public JobCalculateBalance(INotificationBusiness notificationBusiness)
{
this.notificationBusiness = notificationBusiness;
}
public void Execute()
{
notificationBusiness.Create(new Notification());
}
}
And the setup
[code] public class SetupRecurringJob : ISetupJob
{
public SetupRecurringJob()
{
}
public void Configure()
{
RecurringJob.AddOrUpdate<JobCalculateBalance>(x => x.Execute(), Cron.Daily(1, 0), TimeZoneInfo.Local);
}
[/code]
Error
Failed An exception occurred during processing of a background job.
System.MissingMethodException
Nenhum construtor sem parâmetros foi definido para este objeto.
System.MissingMethodException: Nenhum construtor sem parâmetros foi definido para este objeto.
em System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
em System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
em System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
em System.Activator.CreateInstance(Type type, Boolean nonPublic)
em System.Activator.CreateInstance(Type type)
em Hangfire.JobActivator.ActivateJob(Type jobType)
em Hangfire.JobActivator.SimpleJobActivatorScope.Resolve(Type type)
em Hangfire.Server.CoreBackgroundJobPerformer.Perform(PerformContext context)
em Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass3.<PerformJobWithFilters>b__0()
em Hangfire.Server.BackgroundJobPerformer.InvokePerformFilter(IServerFilter filter, PerformingContext preContext, Func`1 continuation)
em Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass3.<>c__DisplayClass5.<PerformJobWithFilters>b__2()
em Hangfire.Server.BackgroundJobPerformer.PerformJobWithFilters(PerformContext context, IEnumerable`1 filters)
em Hangfire.Server.BackgroundJobPerformer.Perform(PerformContext context)
em Hangfire.Server.Worker.PerformJob(BackgroundProcessContext context, IStorageConnection connection, String jobId)