Sek*_*tor 7 c# quartz.net asp.net-core-mvc quartz asp.net-core-2.0
我正在尝试在我的 asp core 2.0 项目中使用 Quartz sheduker。我使用 nuget 下载了 Quartz 3.0.4,之后添加了 services.AddQuartz(new QuartezOptions {}); Startup.cs中的ConfigureService函数
我对 app.UseQuartz() 也有同样的问题
这就是 Startup.cs 现在的样子:
using AspProj.Map;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.Swagger;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Quartz;
namespace AspProj
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<CacheDbContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("DB")));
services.AddScoped<CacheDbContext>();
services.AddMvc();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "API", Version = "v1" });
});
services.AddQuartz(new QuartezOptions { });
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "DbApi V1");
});
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseQuartz();
}
}
Run Code Online (Sandbox Code Playgroud)
}
我尝试通过using连接不同的Quartz命名空间,但没有用。我只是不断从 Visual Studio 2017 收到“IServiceCollection 不包含 AddQuartz 的定义”。
错误屏幕截图 我找不到与我有相同问题的人的任何信息。有人知道吗,我该如何解决这个问题?
Yan*_*ann 13
尝试在您的依赖项中添加 Quartz 命名空间,这应该可以工作:
using Quartz;
还要确保已安装正确的软件包:
dotnet add package Quartz.Extensions.Hosting
| 归档时间: |
|
| 查看次数: |
3123 次 |
| 最近记录: |