Hangfire server unable to pick jobs when Windows service is hosted in release mode
我正在Windows Service中托管hangfire服务器,以便在ps启动时hangfire服务器自动启动并开始执行作业。
现在的问题是,当我在
但是当我以发布模式托管Windows服务以及共享库时,出现以下错误:
Could not load file or assembly 'ClassLibrary1.SharedLibrary,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. An attempt was made to load a program with an incorrect
format.
我的Windows服务在
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | public partial class MyNewService1 : ServiceBase { private BackgroundJobServer _server; private System.Diagnostics.EventLog eventLog1; public MyNewService1() { InitializeComponent(); eventLog1 = new System.Diagnostics.EventLog(); if (!System.Diagnostics.EventLog.SourceExists("MySource")) { System.Diagnostics.EventLog.CreateEventSource( "MySource","MyNewLog"); } eventLog1.Source ="MySource"; eventLog1.Log ="MyNewLog"; GlobalConfiguration.Configuration.UseSqlServerStorage("connectionstring"); } protected override void OnStart(string[] args) { eventLog1.WriteEntry("In OnStart", EventLogEntryType.Information); _server = new BackgroundJobServer(); } protected override void OnStop() { _server.Dispose(); } } |
我从以下参考资料中获取了代码:http://docs.hangfire.io/en/latest/background-processing/processing-jobs-in-windows-service.html
在文档上没有提及任何内容,例如我是否应在调试/发布模式下托管Windows服务。
这是Windows服务还是Hangfire问题?
更新:我认为问题与此处所述的Windows服务有关,但还是没有运气:
在发布模式下生成时发生System.BadImageFormatException
实际上,问题与许可有关,我必须从
有了这个,我得到了下面这个链接的回答,它解决了我的问题:
在发布模式下生成时发生System.BadImageFormatException