我克隆了一个基于.NET 8的ASP.NET Core项目。IDE是VisualStudio 22 17.9,它编译得很好。但是启动后打开swagger页面就报错,程序最终没有运行起来
InvalidOperationException: Failed to create instance of type 'Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionProvider'. Possible reason is cannot match the best constructor of type 'Microsoft.AspNetCore.Mvc.ApiExplorer.EndpointMetadataApiDescriptionProvider'.
项目作者是我的一位同事,他能够正确运行它。我和他使用同样的环境。
我检查了Nuget,应该不会丢失。 我尝试重新安装 VisualStudio,但这并没有解决问题。 我查阅了微软官方文档,看起来 IApiDescriptionProvider 都是关于 Controller 中的属性,例如 [HttpGet]、[HttpPost]。 (我不知道) 我尝试运行前台程序,请求报服务异常。