admin管理员组文章数量:1295066
I have an ASP.NET Core 9 Web API project that is created from the standard template in Visual Studio with no changes.
This is a fresh project that VS created, and I click run and get the following error
System.InvalidOperationException: 'Cannot resolve scoped service 'Microsoft.Extensions.Options.IOptionsSnapshot`1[Microsoft.AspNetCore.OpenApi.OpenApiOptions]' from root provider.'
What on earth is happening? Surely it should just run, otherwise what is the point in the template?
This is the program.cs
file:
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring OpenAPI at
builder.Services.AddOpenApi();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
}
If I create a new 8 WebApi project it works fine.
本文标签:
版权声明:本文标题:.net 9.0 - "Cannot resolve scoped service 'Microsoft.Extensions.Options.IOptionsSnapshot" in new ASP.N 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738491333a2089723.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论