c# - Hangfire + SimpleInjector + MVC
问题描述
我正在尝试为我们的 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 模板项目,它仍然给我同样的错误:皱眉:
你们有什么想法我错过了吗?非常感谢您对此的任何帮助。
谢谢
解决方案
推荐阅读
- jpeg - 使用英特尔 IPP 解压缩无损 JPEG
- python - 不断收到此错误“AF_INET 地址必须是元组,而不是套接字”。不知道如何解决它是什么意思
- jenkins - jenkins 中是否有一个插件来限制字符串参数的字符输入?
- r - 关于 R for 循环和 if 语句的一个实际问题
- python - 如何修复`警告:错误的管道:没有元素“疯狂”`
- architecture - 寻找下载大文件的架构
- c++ - 如何在虚拟机上使用 Visual Studio 设置内核调试器
- c++ - 在 C++ 中绘制 Windows 10 壁纸
- azure - azure-arm winrm 使用打包程序超时错误
- python - Context Locals 和 The Request Context 如何协同工作?