赞
踩
An error occurred while starting the application.
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’: No constructor for type ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’ can be instantiated using services from the service container and default values.) (Error while validating the service descriptor ‘ServiceType: Microsoft.Extensions.ApiDescriptions.IDocumentProvider Lifetime: Singleton ImplementationType: Microsoft.Extensions.ApiDescriptions.DocumentProvider’: No constructor for type ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’ can be instantiated using services from the service container and default values.) (Error while validating the service descriptor ‘ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’: No constructor for type ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’ can be instantiated using services from the service container and default values.)
Microsoft.Extensions.DependencyInjection.ServiceProvider…ctor(IEnumerable serviceDescriptors, ServiceProviderOptions options)
InvalidOperationException: Error while validating the service descriptor ‘ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’: No constructor for type ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’ can be instantiated using services from the service container and default values.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor ‘ServiceType: Microsoft.Extensions.ApiDescriptions.IDocumentProvider Lifetime: Singleton ImplementationType: Microsoft.Extensions.ApiDescriptions.DocumentProvider’: No constructor for type ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’ can be instantiated using services from the service container and default values.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor ‘ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’: No constructor for type ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’ can be instantiated using services from the service container and default values.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
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’: No constructor for type ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’ can be instantiated using services from the service container and default values.) (Error while validating the service descriptor ‘ServiceType: Microsoft.Extensions.ApiDescriptions.IDocumentProvider Lifetime: Singleton ImplementationType: Microsoft.Extensions.ApiDescriptions.DocumentProvider’: No constructor for type ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’ can be instantiated using services from the service container and default values.) (Error while validating the service descriptor ‘ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’: No constructor for type ‘Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’ can be instantiated using services from the service container and default values.)
Microsoft.Extensions.DependencyInjection.ServiceProvider…ctor(IEnumerable serviceDescriptors, ServiceProviderOptions options)
Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder)
Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter.CreateServiceProvider(object containerBuilder)
Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
Microsoft.Extensions.Hosting.HostBuilder.Build()
Swagger.Program.Main(string[] args) in Program.cs
1.以.net3.0为基础环境,安装的swagger版本须为5.0.0.0-rc4
2.在startup中进行如下配置
引用OpenAI,并注册、启用
记得检查下这里是否为,否则就会犯和我一样的错误。
我的报错的原因是因为使用的模板是COREWEB应用,应当选择CoreWebAPI
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。