[Swagger]Unable to resolve service for type “Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionGroupCollectionProvider” while attempting to activate

Ortam ve Proje Tipi;

Net Core 5.0

Hata Mesajı ;

System.AggregateException:“Some services are not able to be constructed (Error while validating the service descriptor ‘ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator‘: Unable to resolve service for type ‘Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionGroupCollectionProvider‘ while attempting to activate ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator‘.) (Error while validating the service descriptor ‘ServiceType: Microsoft.Extensions.ApiDescriptions.IDocumentProvider Lifetime: Singleton ImplementationType: Microsoft.Extensions.ApiDescriptions.DocumentProvider‘: Unable to resolve service for type ‘Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionGroupCollectionProvider‘ while attempting to activate ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator‘.)”

Çözüm ;

Özellikle RazorPages versiyonunda, services.AddMvc(); satırını ConfigureServices metodu içinde yazmanız gerekmektedir.