question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.net core 3.0 pre9 Swashbuckle.AspNetCore5.0 error

See original GitHub issue

System.AggregateException HResult=0x80131500 Message=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’: Failed to compare two elements in the array.) (Error while validating the service descriptor ‘ServiceType: Swashbuckle.AspNetCore.SwaggerGen.ISchemaRegistryFactory Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SchemaRegistryFactory’: Failed to compare two elements in the array.) Source=Microsoft.Extensions.DependencyInjection StackTrace: at Microsoft.Extensions.DependencyInjection.ServiceProvider…ctor(IEnumerable1 serviceDescriptors, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder) at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter1.CreateServiceProvider(Object containerBuilder) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build() at Paperlee.FOStock.WebAPI.Program.Main(String[] args) in G:\selfproj\FOStock\Paperlee.FOStock.WebAPI\Program.cs:line 17

内部异常 1: InvalidOperationException: Error while validating the service descriptor ‘ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator’: Failed to compare two elements in the array.

内部异常 2: InvalidOperationException: Failed to compare two elements in the array.

内部异常 3: TypeLoadException: Could not load type ‘Microsoft.AspNetCore.Mvc.MvcJsonOptions’ from assembly ‘Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60’.

startup.cs

public void ConfigureServices(IServiceCollection services) { services.AddControllers(options => { options.Filters.Add<ActionFilter>(); }); services.AddCors(options => { options.AddPolicy(“AllowAllOrigin”, builder => { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials(); }); }); services.AddSwaggerGen(options => { options.SwaggerDoc(“v1”, new Info { Version = “Version 1.0”, Title = “通用数据API”, Description = “Author:Lee” }); options.OperationFilter<OAuthHeaderParameter>(); SwaggerHelper.LoadXml(options, new string[] { “JQProject.FOStock.IApp.xml”, “JQProject.FOStock.WebAPI.xml” }, AppContext.BaseDirectory); }); //new StartupConfig().Init(services); }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
carlblanchardcommented, Nov 23, 2019

Brubning thanks for the pointer… working great now. I have to change the signature to services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Put title here", Description = "DotNet Core Api 3 - with swagger" }); });

11reactions
sommmencommented, Oct 16, 2019

I am having the same issue, running .net core 3. everything is the latest version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception when adding swagger with .NET Core 3.0
This is usually due to usage of wrong swagger package and as a result the Info api is using Swashbuckle.AspNetCore.Swagger.Info which caused the ......
Read more >
Get started with Swashbuckle and ASP.NET Core
Learn how to add Swashbuckle to your ASP.NET Core web API project to integrate the Swagger UI.
Read more >
Using Swagger In .NET Core 3+
Again, the fix is to ensure you are running version 5.0.0 or above of Swashbuckle. Adding Swagger Services. The next step is to...
Read more >
Swashbuckle.AspNetCore
Swagger tooling for APIs built with ASP.NET Core. Generate beautiful API documentation, including a UI to explore and test operations, directly from your ......
Read more >
Using OpenAPI with .NET Core
In this section, we'll use the open source Swashbuckle.AspNetCore package to provide an OpenAPI description of an ASP.NET Core application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found