Quartz.NET 中无法加载作业程序集错误

发布于 2024-11-17 19:42:09 字数 746 浏览 3 评论 0原文

我使用 Quartz.NET 调度程序作为独立的 Windows 服务,同时从 ASP.NET 应用程序安排作业。我有一个单独的作业程序集,但收到以下错误

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

这是我的代码,

        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 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

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.

Here is my code,

        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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

平安喜乐 2024-11-24 19:42:09

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

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

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

Although already answered (in comments), I am adding an answer here for future reference.

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).

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文