我安装了 HangFire 软件包并在 Startup.cs 中进行了一些更改 构建代码后,我收到此错误:“dotnet 意外退出”。
启动文件
public void ConfigureServices (IServiceCollection services) {
services.AddHangfire(configuration=>{
configuration.UseSqlServerStorage("ConnectionStrings:DefaultConnection");
});
services.AddMvc();
// Add framework services.
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure (IApplicationBuilder app, IHostingEnvironment env) {
app.UseHangfireServer();
app.UseHangfireDashboard();
}
问题在于 Configure() 中有 2 行。app.UseHangFireServer() 和 app.UseHangfireDashboard();
当我删除这两个时,它运行良好。
我试过:删除nuget缓存并恢复。在终端和项目中检查 dotnet --version 并且它们都是相同的(2.2.106)
更新:我修复了在构建代码时遇到问题的部分。问题是我使用的是 UseSqlServerStorage 而不是 UsePostgreSqlServerStorage。
我现在有另一个问题:我无法访问仪表板。http://localhost:5000/hangfire页面不存在。
初始化 Hangfire 时似乎出现错误,导致应用程序启动崩溃。这可能是因为连接字符串不正确、数据库不可访问或数据库系统不兼容。看起来您在配置 Hangfire 以使用 SQL Server 时正在使用 PostgreSQL。
您可能想查看这个包含 PostgreSQL 的 Hangfire 实现的包:https ://www.nuget.org/packages/Hangfire.PostgreSql/ 。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句