Hangfire + SimpleInjector + MVC

时间:2018-11-08 21:33:17

标签: c# hangfire

我正在尝试为我们的MVC应用设置Hangfire。我遵循了所有教程,将Devmondo HangFire.SimpleInjector用于激活器逻辑,但是仍然有问题。

我的启动设置如下:

//Hangfire
Hangfire.GlobalConfiguration.Configuration.UseSqlServerStorage(webClientConfigurationService.DataConnectionStringName);
Hangfire.GlobalConfiguration.Configuration.UseActivator(new SimpleInjectorJobActivator(Core.Dependencies.DependencyResolver.Container));
app.UseHangfireDashboard();
app.UseHangfireServer();

        //add hangfire test job
        var _selfAccreditationsService = Core.Dependencies.DependencyResolver.Resolve<ISelfAccreditationsService>();
        RecurringJob.AddOrUpdate(() => _selfAccreditationsService.TestHangFire(), Cron.MinuteInterval(1));

应用程序启动正常,但是当我进入仪表板时,我可以看到:

System.TypeLoadException: Could not load type ‘SimpleInjector.Lifestyles.AsyncScopedLifestyle’ from assembly ‘SimpleInjector, Version=3.1.2.0, Culture=neutral, PublicKeyToken=984cb50dea722e99’.
at Hangfire.SimpleInjector.SimpleInjectorJobActivator.BeginScope(JobActivatorContext context)
at Hangfire.Server.CoreBackgroundJobPerformer.Perform(PerformContext context)
at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_0.b__0()
at Hangfire.Server.BackgroundJobPerformer.InvokePerformFilter(IServerFilter filter, PerformingContext preContext, Func1 continuation) at Hangfire.Server.BackgroundJobPerformer.PerformJobWithFilters(PerformContext context, IEnumerable1 filters)
at Hangfire.Server.BackgroundJobPerformer.Perform(PerformContext context)
at Hangfire.Server.Worker.PerformJob(BackgroundProcessContext context, IStorageConnection connection, String jobId)

编辑:即使添加了上述所有内容之后,即使使用了新的MVC模板项目,它仍然给我同样的错误:皱着眉头:

你们有什么想法我错过了吗?非常感谢您提供任何帮助。

谢谢

0 个答案:

没有答案
相关问题