C# hangfire无法加载文件或程序集';动态加氧总成2
我已经设置了Hangfire,如下所示:C# hangfire无法加载文件或程序集';动态加氧总成2,c#,hangfire,C#,Hangfire,我已经设置了Hangfire,如下所示: var t = IocManager.Resolve<TestJob>(); RecurringJob.AddOrUpdate("sendDailyEmail",() => t.sendEmail(), Cron.Daily); var t=IocManager.Resolve(); RecurringJob.AddOrUpdate(“sendDailyEmail”,()=>t.sendEmail(),Cron.Daily);
var t = IocManager.Resolve<TestJob>();
RecurringJob.AddOrUpdate("sendDailyEmail",() => t.sendEmail(), Cron.Daily);
var t=IocManager.Resolve();
RecurringJob.AddOrUpdate(“sendDailyEmail”,()=>t.sendEmail(),Cron.Daily);
当我访问Hangfire仪表板时,我可以看到重复作业1,但该作业未执行,因此出现以下错误:
无法加载文件或程序集“DynamicProxyGenAssembly2,版本=0.0.0.0,区域性=中性,PublicKeyToken=null”或其依赖项之一。系统找不到指定的文件
我的设置有什么问题?可能与您的上下文不一样,但我认为还是值得在此处添加它:
-Hangfire服务器作为Windows服务运行
-运行在ASP.NET MVC 5应用程序之上的Hangfire仪表板
-作业实际上正在运行,但仪表板一直显示FileNotFoundException
解决方案:添加了对仪表板web应用程序中缺少的程序集(即:“DynamicProxyGenAssembly2”)的引用 @reggieboyYEAH以同样的方式报告和解决了相同的问题
这里的详细信息:在我的例子中,我使用Autofac作为DI容器,并注册我加入队列/AddOrUpdate的方法。EnableInterfaceInterceptors(),在我短暂地从Hangfire切换到托管服务时启用拦截,例如
builder.RegisterType<ExPartInvoiceBatchService>().As<IExPartInvoiceBatchService>().InstancePerDependency().EnableInterfaceInterceptors();
builder.RegisterType().As().InstancePerDependence().EnableInterfaceInterceptors();
不管怎么说,当我切换回时,这些进程开始抛出这些错误。如果使用SQL进行序列化,可以查看Hangfire.Hash表中Field='Job'的行,并查看有问题的条目的序列化方式与正常工作的条目的序列化方式不同。为什么?我不知道,但我摆脱了拦截功能,恢复了一切正常工作。你有过这样的工作吗?你解决了吗?