无法在 Quartz.NET 中加载作业程序集错误 [英] Could not load job assembly error in Quartz.NET

查看:79
本文介绍了无法在 Quartz.NET 中加载作业程序集错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Quartz.NET 调度程序作为独立的 Windows 服务,而我从 ASP.NET 应用程序中调度作业.我有一个单独的作业程序集,但出现以下错误

I'm using Quartz.NET scheduler as a stand-alone windows service while from an ASP.NET app I sechedule jobs. I've a separate job assembly and i'm getting the following error

无法加载文件或程序集AV.Scheduler.Jobs,版本=1.0.0.0,Culture=neutral,PublicKeyToken=null"或其依赖项之一.系统找不到指定的文件.

Could not load file or assembly 'AV.Scheduler.Jobs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

这是我的代码,

        JobDetail jobDetail = new JobDetail("testJob", null, typeof(TestJob));

        //created trigger which will fire every minute starting immediately
        SimpleTrigger trigger = new SimpleTrigger("testTrigger",
                                null,
                                DateTime.UtcNow,
                                null,
                                1,
                                TimeSpan.FromMinutes(1));

        scheduler.ScheduleJob(jobDetail, trigger);

我在最后一行收到错误.

I'm getting the error at the last line.

推荐答案

虽然已经回答(在评论中),但我在这里添加一个答案以供将来参考.

为了让 Quartz 服务执行您的自定义作业,它需要能够以某种方式定位作业程序集.正如您所建议的,一种解决方案是将其添加为对启动和停止 Quartz 服务的控制台应用程序的引用.但是,控制台应用程序并不总是存在.如果是这种情况,您需要将作业程序集放在 Quartz.dll 所在的文件夹中(服务使用的 dll 版本).

In order for the Quartz service to execute your custom job, it needs to be somehow able to locate the job assembly. One solution is, as you suggested, to add it as a reference to the console application that starts and stops the Quartz service. However, a console application isn't always present. If this is the case, you need to place the job assembly in the same folder that Quartz.dll is located (the version of the dll that is used by the service).

Quartz.Net 的一个很好的资源是 http://jvilalta.blogspot.com/.以下博客文章对此主题特别感兴趣:

An excellent resource for Quartz.Net is http://jvilalta.blogspot.com/. From particular interest regarding this topic are the following blog posts:

这篇关于无法在 Quartz.NET 中加载作业程序集错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆