将 Quartz 与 Topshelf 一起使用时出现异常

Exception when using Quartz with Topshelf

我在尝试 运行 Topshelf with Quartz 时遇到错误

Topshelf.Hosts.ConsoleRunHost Error: 0 : An exception occurred, System.TypeLoadException: Could not load type 
'Quartz.Collection.HashSet`1' from assembly 'Quartz, Version=3.0.7.0, Culture=neutral, PublicKeyToken=*'.
   at Topshelf.Quartz.ScheduleJobServiceConfiguratorExtensions.<>c__DisplayClassa`1.<ConfigureJob>b__3()
   at Topshelf.Runtime.EventCallbackList`1.Notify(T data)
   at Topshelf.Builders.DelegateServiceBuilder`1.DelegateServiceHandle.Start(HostControl hostControl)
   at Topshelf.Hosts.ConsoleRunHost.Run()

我的密码是

HostFactory.Run(x =>
        {
            x.Service<Service>(s =>
            {
                s.WhenStarted(service => service.Start());
                s.WhenStopped(service => service.Stop());
                s.ConstructUsing(() => new Service());

                s.ScheduleQuartzJob(q =>
                    q.WithJob(() =>
                            JobBuilder.Create<Notifications>().Build())
                        .AddTrigger(() => TriggerBuilder.Create()
                            .WithSimpleSchedule(b => b.WithIntervalInSeconds(10)
                                .RepeatForever())
                            .Build()));
            });

            x.RunAsLocalSystem()
                .StartAutomatically();

            x.SetDescription("Quartz Service");
            x.SetDisplayName("QuartzService");
            x.SetServiceName("QuartzService");
        });

我似乎无法通过 google 搜索找到与 Quartz.Collection.Hashset 相关的任何内容,如果它丢失了,我不确定如何获取它。

我已将其归因于 Quartz.Topshelf Nuget 包不支持 .net 核心,不得不求助于创建 windows 服务。

看来您可以使用 .net core 3.0 及更高版本创建一些非常简单的服务。所以它使 Topshelf 几乎过时了。所以这绝对是一个更好的选择。

将此标记为答案,除非有人找到此问题并找到解决方案

您使用的 NuGet 包已过时。我 运行 陷入了确切的错误,不得不编写自己的集成。如果你在 NuGet 上使用 dtnuget 包,你肯定会遇到这个问题;该包最后一次更新是在 2015 年。您最好的选择是使用 bertuko 发布的 NuGet 包。我已经使用他的实现作为我自己的基础,并且工作正常。