为什么在Windows服务中运行的Quartz.NET在Debug中工作得很好,但在Release中却没有?

时间:2014-12-04 23:12:22

标签: windows-services quartz.net

我已经创建了一个在Windows服务中运行自托管(OWIN)的Web API应用程序。应用程序的Web API部分是用于向Quartz.NET提交作业的包装器。我使用AdoJobStore进行工作持久性。

在Debug模式下构建时,整个过程非常漂亮。我甚至有单位测试它提交作业,阅读它们,然后删除它们。测试完美无缺。但是当我在发布模式下运行它时,服务无法启动并给我:

  

错误1053:服务未及时响应启动或控制请求

当我深入研究日志时,我发现根错误是:

  

异常信息:System.IO.FileNotFoundException   堆:      在Quartz.Impl.StdSchedulerFactory.Initialize()      在Quartz.Impl.StdSchedulerFactory.GetScheduler()      在ARI.Scheduler.WindowsService.Program.Main()

我的第一个想法是Release文件夹中必须缺少App.config。但确实存在。所以,我尝试以编程方式配置StdSchedulerFactory。但错误仍然存​​在。

修改

好的,再深入挖掘一下,我在try-catch中包含了对GetScheduler()的调用,并且我将基本异常写入了EventLog。这个消息:

  

异常信息:System.TypeInitializationException   堆:      在Quartz.Impl.StdSchedulerFactory.ValidateConfiguration()      在Quartz.Impl.StdSchedulerFactory.Initialize(System.Collections.Specialized.NameValueCollection)      在ARI.Scheduler.WindowsService.Program.InitializeScheduler()      在ARI.Scheduler.WindowsService.Program.Main()

我在这个人的头上撞到了我的头。任何来自Quartz.NET团队的帮助都将不胜感激。感谢。

1 个答案:

答案 0 :(得分:1)

狗娘养。这是一个log4net程序集版本不匹配。天哪!!!

<dependentAssembly>
    <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.2.11.0" newVersion="1.2.11.0" />
</dependentAssembly>

需要:

<dependentAssembly>
    <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.2.11.0" newVersion="1.2.13.0" />
</dependentAssembly>

请注意1.2.13.0中的 3 ,而不是1.2.11.0。这篇帖子让我觉得这可能是一个装配问题:The type initializer for 'Quartz.Impl.StdSchedulerFactory' threw an exception

猜猜我最好更好地关注我的装配版本。我仍然不明白为什么Debug模式工作得很好,因为Debug和Release当前都使用相同的App.config。怪异。