I’ve updated Hangfire to 1.4 version and got some bug.
When job starts it fails with error (seen at Dashboard):
System.MissingMethodExceptionNo parameterless constructor defined for this object.
I know with this error, but I cannot understand what is wrong. I use LightInject IoC-container and delegate call to create instance to it. Look:
Config:
GlobalConfiguration.Configuration
.UseActivator(new ContainerJobActivator(container));
.UseSqlServerStorage(
"database",
new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = false
});
app.UseHangfireServer();
Activator code:
public class ContainerJobActivator : JobActivator
{
private ServiceContainer _container;
public ContainerJobActivator(ServiceContainer container)
{
_container = container;
}
public override object ActivateJob(Type type)
{
using (_container.BeginScope())
{
return _container.GetInstance(type);
}
}
}
But when I connect to app through debugger, ActivateJob is never called.
I see this problem only at server. By other words whn I run application at my work machine from VS there is no problem: activator is called, job runs. The problem appears when I publish app to a server.
Versions of .NET are same at both of machines.
What kind of additional information can I give to find a reason of this issue?