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

时间:2021-04-13 12:19:16   收藏:0   阅读:0

详细错误如下

===================

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‘.)”

环境

===================

环境NetCore5.0

VS:2019

 

解决方案

==========================

参考:https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-5.0&tabs=visual-studio

需要在ConfigureServices添加 services.AddMvc();

技术图片

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!