Open Closed

Unable to resolve errors with ConfigureSwaggerOptions and SwaggerDefaultValues in ConfigureServices #8123


User avatar
0
suresht created
  • ABP Framework version: v8.3.0
  • UI Type: Angular
  • Database System: SQL Server
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: The type or namespace name 'ConfigureSwaggerOptions' could not be found (are you missing a using directive or an assembly reference?) The type or namespace name 'SwaggerDefaultValues' could not be found (are you missing a using directive or an assembly reference?)
  • Steps to reproduce the issue:
    • We are using Auto API Controller implementation and trying to make use of versioning. We are following the example provided at:
    • https://abp.io/docs/latest/framework/api-development/versioning
    • Following is the code in the module class of HttpApi project
using Asp.Versioning;
using Asp.Versioning.ApplicationModels;
using Localization.Resources.AbpUi;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.SwaggerGen;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;



[DependsOn(
    typeof(ProjectApplicationContractsModule),
    typeof(ProjectApplicationModule),
    typeof(AbpAspNetCoreMvcModule))]
public class ProjectHttpApiModule : AbpModule
{
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        //PreConfigure<IMvcBuilder>(mvcBuilder =>
        //{
        //    mvcBuilder.AddApplicationPartIfNotExists(typeof(ProjectHttpApiModule).Assembly);
        //});

        PreConfigure<AbpAspNetCoreMvcOptions>(options =>
        {
            //2.0 Version
            options
                .ConventionalControllers
                .Create(typeof(ProjectApplicationModule).Assembly, opts =>
                {
                    opts.TypePredicate = t => t.Namespace == typeof(CapsPay.v2.CapspayprojectAppService).Namespace;
                    opts.ApiVersions.Add(new ApiVersion(2, 0));
                });

            //1.0 Compatibility version
            options
                .ConventionalControllers
                .Create(typeof(ProjectApplicationModule).Assembly, opts =>
                {
                    opts.TypePredicate = t => t.Namespace == typeof(CapsPay.v1.CapspayprojectAppService).Namespace;
                    opts.ApiVersions.Add(new ApiVersion(1, 0));
                });
        });
    }

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        Configure<AbpLocalizationOptions>(options =>
        {
            options.Resources
                .Get<ProjectResource>()
                .AddBaseTypes(typeof(AbpUiResource));
        });

        var preActions = context.Services.GetPreConfigureActions<AbpAspNetCoreMvcOptions>();

        Configure<AbpAspNetCoreMvcOptions>(options =>
        {
            options.ConventionalControllers
                .Create(typeof(ProjectApplicationModule).Assembly, opts =>
                {
                    opts.RootPath = "project";
                });

            preActions.Configure(options);
        });

        // Show neutral/versionless APIs.
        context.Services.AddTransient<IApiControllerFilter, NoControllerFilter>();

        context.Services.AddAbpApiVersioning(options =>
        {
            options.ReportApiVersions = true;

            options.AssumeDefaultVersionWhenUnspecified = true;

            //options.ConfigureAbp(preActions.Configure());
        }).AddApiExplorer(options => {
            // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service
            // note: the specified format code will format the version as "'v'major[.minor][-status]"
            options.GroupNameFormat = "'v'VVV";

            // note: this option is only necessary when versioning by url segment. the SubstitutionFormat
            // can also be used to control the format of the API version in route templates
            options.SubstituteApiVersionInUrl = true;
        });

        context.Services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();

        context.Services.AddAbpSwaggerGen(options =>
        {
            // add a custom operation filter which sets default values
            options.OperationFilter<SwaggerDefaultValues>();

            options.CustomSchemaIds(type => type.FullName);
        });

        Configure<AbpAspNetCoreMvcOptions>(options =>
        {
            options.ChangeControllerModelApiExplorerGroupName = false;
        });
    }
}

What package(s) need to be installed to resolve errors for "ConfigureSwaggerOptions" and "SwaggerDefaultValues"?

Thanks.


6 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello ,

    Can you please check this similar issue if it helps you https://abp.io/support/questions/1894/How-to-use-Swagger-API-versioning-with-tiered-project

    Thanks,

  • User Avatar
    0
    suresht created

    Hello ,

    Can you please check this similar issue if it helps you https://abp.io/support/questions/1894/How-to-use-Swagger-API-versioning-with-tiered-project

    Thanks,

    Hi Anjali,

    I went through the above link and also the details found at: https://github.com/abpframework/abp-samples/tree/master/Api-Versioning

    The support link you listed is 3 years old and I was able to sort out some compilation issues by finding details from the above github link.

    I am receiving the following error message in the Module class of Micro Services:

    Here is the code for this class:

    [DependsOn(
        typeof(ProjectHttpApiModule),
        typeof(ProjectEntityFrameworkCoreModule),
        typeof(ProjectApplicationModule),
        typeof(ProjectApplicationContractsModule),
        typeof(BlobStoringDatabaseEntityFrameworkCoreModule),
        typeof(AbpSettingManagementEntityFrameworkCoreModule),
        typeof(LanguageManagementEntityFrameworkCoreModule),
        typeof(AbpPermissionManagementEntityFrameworkCoreModule),
        typeof(AbpFeatureManagementEntityFrameworkCoreModule),
        typeof(AbpEntityFrameworkCoreSqlServerModule),
        typeof(IntegrationServicesProjectServiceContractsModule),
        typeof(AbpAutofacModule),
        typeof(AbpAspNetCoreSerilogModule),
        typeof(AbpSwashbuckleModule),
        typeof(AbpAspNetCoreMvcModule),
        typeof(AbpEventBusRabbitMqModule),
        typeof(AbpBackgroundJobsRabbitMqModule),
        typeof(AbpCachingStackExchangeRedisModule),
        typeof(AbpDistributedLockingModule),
        typeof(AbpStudioClientAspNetCoreModule),
        typeof(AbpAuditLoggingEntityFrameworkCoreModule)
        )]
    public class IntegrationServicesProjectServiceModule : AbpModule
    {
        public override void PreConfigureServices(ServiceConfigurationContext context)
        {
            PreConfigure<AbpAspNetCoreMvcOptions>(options =>
            {
                //2.0 Version
                options
                    .ConventionalControllers
                    .Create(typeof(IntegrationServicesProjectServiceModule).Assembly, opts =>
                    {
                        opts.TypePredicate = t => t.Namespace == typeof(Controllers.ConventionalControllers.v2.TodoAppService).Namespace;
                        opts.ApiVersions.Add(new ApiVersion(2, 0));
                    });
    
                //1.0 Compatibility version
                options
                    .ConventionalControllers
                    .Create(typeof(IntegrationServicesProjectServiceModule).Assembly, opts =>
                    {
                        opts.TypePredicate = t => t.Namespace == typeof(Controllers.ConventionalControllers.v1.TodoAppService).Namespace;
                        opts.ApiVersions.Add(new ApiVersion(1, 0));
                    });
            });
        }
    
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            var configuration = context.Services.GetConfiguration();
    
            var env = context.Services.GetHostingEnvironment();
    
            var redis = CreateRedisConnection(configuration);
    
            ConfigurePII(configuration);
            ConfigureJwtBearer(context, configuration);
            ConfigureCors(context, configuration);
            ConfigureSwagger(context, configuration);
            ConfigureDatabase(context);
            ConfigureDistributedCache(configuration);
            ConfigureDataProtection(context, configuration, redis);
            ConfigureDistributedLock(context, redis);
            ConfigureDistributedEventBus();
            ConfigureIntegrationServices();
            ConfigureAntiForgery(env);
            ConfigureVirtualFileSystem();
            ConfigureObjectMapper();
            ConfigureAutoControllers();
            ConfigureDynamicClaims(context);
            Configure<AbpAuditingOptions>(options =>
            {
                options.IsEnabled = true;
                options.IsEnabledForGetRequests = true;
                options.HideErrors = false;
                options.IsEnabledForAnonymousUsers = true;
                options.AlwaysLogOnException = true;
                options.IsEnabledForIntegrationServices = true;
                options.ApplicationName = "ProjectService";
            });
    
            #region Configure Versioning
    
            ////context.Services.AddTransient<IApiControllerFilter, NoControllerFilter>();
    
            ////context.Services.AddAbpApiVersioning(options =>
            ////{
            ////    options.ReportApiVersions = true;
            ////    options.AssumeDefaultVersionWhenUnspecified = true;
            ////});
    
            ////Configure<AbpAspNetCoreMvcOptions>(options =>
            ////{
            ////    options.ChangeControllerModelApiExplorerGroupName = false;
            ////});
    
            //context.Services.AddApiVersioning();
    
            #endregion
    
            if (!env.IsDevelopment())
            {
                Configure<AbpRabbitMqOptions>(options =>
                {
                    options.Connections.Default.UserName = configuration["RabbitMQ:Connections:Default:UserName"];
                    options.Connections.Default.Password = configuration["RabbitMQ:Connections:Default:Password"];
                    options.Connections.Default.HostName = configuration["RabbitMQ:Connections:Default:HostName"];
                    options.Connections.Default.Port = 5671;
                    options.Connections.Default.Ssl = new RabbitMQ.Client.SslOption
                    {
                        Enabled = true,
                        ServerName = configuration["RabbitMQ:Connections:Default:HostName"]
                    };
    
                    options.Connections.Default.VirtualHost = configuration["RabbitMQ:Connections:Default:VirtualHost"];
                });
            }
        }
    
        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
            var app = context.GetApplicationBuilder();
            var env = context.GetEnvironment();
            var configuration = context.GetConfiguration();
    
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
    
            app.UseCorrelationId();
            app.UseAbpRequestLocalization();
            app.UseStaticFiles();
            app.UseAbpStudioLink();
            app.UseCors();
            app.UseRouting();
            app.UseHttpMetrics();
            app.UseAuthentication();
            app.UseAbpClaimsMap();
            app.UseAuthorization();        
    
            if (IsSwaggerEnabled(configuration))
            {
                app.UseSwagger();
                app.UseAbpSwaggerUI(options => { ConfigureSwaggerUI(options, configuration); });
    
                app.UseSwaggerUI(options =>
                {
                    var provider = context.ServiceProvider.GetRequiredService<IApiVersionDescriptionProvider>();
    
                    // builds a swagger endpoint for each API version  
                    foreach (var description in provider.ApiVersionDescriptions)
                    {
                        options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
                    }
    
                    var configuration = context.GetConfiguration();
    
                    options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
                    options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
                });
            }
    
            app.UseAbpSerilogEnrichers();
            app.UseAuditing();
            app.UseUnitOfWork();
            app.UseDynamicClaims();
            app.UseConfiguredEndpoints(endpoints =>
            {
                endpoints.MapMetrics();
            });
        }
    
        public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
        {
            using var scope = context.ServiceProvider.CreateScope();
            await scope.ServiceProvider
                .GetRequiredService<ProjectServiceRuntimeDatabaseMigrator>()
                .CheckAndApplyDatabaseMigrationsAsync();
        }
    
        private ConnectionMultiplexer CreateRedisConnection(IConfiguration configuration)
        {
            return ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
        }
    
        private void ConfigurePII(IConfiguration configuration)
        {
            if (configuration.GetValue<bool>(configuration["App:EnablePII"] ?? "false"))
            {
                Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
            }
        }
    
        private void ConfigureJwtBearer(ServiceConfigurationContext context, IConfiguration configuration)
        {
            context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
                .AddAbpJwtBearer(options =>
                {
                    options.Authority = configuration["AuthServer:Authority"];
                    options.MetadataAddress = configuration["AuthServer:MetaAddress"]!.EnsureEndsWith('/') + ".well-known/openid-configuration";
                    options.RequireHttpsMetadata = configuration.GetValue<bool>(configuration["AuthServer:RequireHttpsMetadata"]);
                    options.Audience = configuration["AuthServer:Audience"];
                });
        }
    
        private void ConfigureVirtualFileSystem()
        {
            Configure<AbpVirtualFileSystemOptions>(options =>
            {
                options.FileSets.AddEmbedded<IntegrationServicesProjectServiceModule>();
            });
        }
    
        private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
        {
            var corsOrigins = configuration["App:CorsOrigins"];
            context.Services.AddCors(options =>
            {
                options.AddDefaultPolicy(builder =>
                {
                    if (corsOrigins != null)
                    {
                        builder
                            .WithOrigins(
                                corsOrigins
                                    .Split(",", StringSplitOptions.RemoveEmptyEntries)
                                    .Select(o => o.RemovePostFix("/"))
                                    .ToArray()
                            )
                            .WithAbpExposedHeaders()
                            .SetIsOriginAllowedToAllowWildcardSubdomains()
                            .AllowAnyHeader()
                            .AllowAnyMethod()
                            .AllowCredentials();
                    }
                });
            });
        }
    
        private void ConfigureSwagger(ServiceConfigurationContext context, IConfiguration configuration)
        {
            if (IsSwaggerEnabled(configuration))
            {
                context.Services.AddAbpSwaggerGenWithOAuth(
                    authority: configuration["AuthServer:Authority"],
                    scopes: new Dictionary<string, string>
                    {
                        {"ProjectService", "ProjectService Service API"}
                    },
                    options =>
                    {
                        options.SwaggerDoc("v1", new OpenApiInfo { Title = "ProjectService API", Version = "v1" });
                        options.DocInclusionPredicate((_, _) => true);
                        options.CustomSchemaIds(type => type.FullName);
                    });
            }
        }
    
        private void ConfigureDatabase(ServiceConfigurationContext context)
        {
            Configure<AbpDbConnectionOptions>(options =>
            {
                options.Databases.Configure("Administration", database =>
                {
                    database.MappedConnections.Add(AbpPermissionManagementDbProperties.ConnectionStringName);
                    database.MappedConnections.Add(AbpFeatureManagementDbProperties.ConnectionStringName);
                    database.MappedConnections.Add(AbpSettingManagementDbProperties.ConnectionStringName);
                    database.MappedConnections.Add(LanguageManagementDbProperties.ConnectionStringName);
                });
    
                options.Databases.Configure("AuditLoggingService", database =>
                {
                    database.MappedConnections.Add(AbpAuditLoggingDbProperties.ConnectionStringName);
                });
            });
    
            context.Services.AddAbpDbContext<ProjectServiceDbContext>(options =>
            {
                options.AddDefaultRepositories();
            });
    
            Configure<AbpDbContextOptions>(options =>
            {
                options.Configure(opts =>
                {
                    /* Sets default DBMS for this service */
                    opts.UseSqlServer();
                });
    
                options.Configure<ProjectServiceDbContext>(c =>
                {
                    c.UseSqlServer(b =>
                    {
                        b.MigrationsHistoryTable("__ProjectService_Migrations");
                    });
                });
            });
        }
    
        private void ConfigureDistributedCache(IConfiguration configuration)
        {
            Configure<AbpDistributedCacheOptions>(options =>
            {
                options.KeyPrefix = configuration["AbpDistributedCache:KeyPrefix"] ?? "";
            });
        }
    
        private void ConfigureDataProtection(ServiceConfigurationContext context, IConfiguration configuration, IConnectionMultiplexer redis)
        {
            context.Services
                .AddDataProtection()
                .SetApplicationName(configuration["DataProtection:ApplicationName"]!)
                .PersistKeysToStackExchangeRedis(redis, configuration["DataProtection:Keys"]);
        }
    
        private void ConfigureDistributedLock(ServiceConfigurationContext context, IConnectionMultiplexer redis)
        {
            context.Services.AddSingleton<IDistributedLockProvider>(
                _ => new RedisDistributedSynchronizationProvider(redis.GetDatabase())
            );
        }
    
        private void ConfigureDistributedEventBus()
        {
            Configure<AbpDistributedEventBusOptions>(options =>
            {
                options.Inboxes.Configure(config =>
                {
                    config.UseDbContext<ProjectServiceDbContext>();
                });
    
                options.Outboxes.Configure(config =>
                {
                    config.UseDbContext<ProjectServiceDbContext>();
                });
            });
        }
    
        private void ConfigureIntegrationServices()
        {
            Configure<AbpAspNetCoreMvcOptions>(options =>
            {
                options.ExposeIntegrationServices = true;
            });
        }
    
        private void ConfigureAntiForgery(IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                Configure<AbpAntiForgeryOptions>(options =>
                {
                    /* Disabling ABP's auto anti forgery validation feature, because
                     * when we run the application in "localhost" domain, it will share
                     * the cookies between other applications (like the authentication server)
                     * and anti-forgery validation filter uses the other application's tokens
                     * which will fail the process unnecessarily.
                     */
                    options.AutoValidate = false;
                });
            }
        }
    
        private void ConfigureObjectMapper()
        {
            Configure<AbpAutoMapperOptions>(options =>
            {
                options.AddMaps<IntegrationServicesProjectServiceModule>(validate: true);
            });
        }
    
        private void ConfigureAutoControllers()
        {
            Configure<AbpAspNetCoreMvcOptions>(options =>
            {
                options
                    .ConventionalControllers
                    .Create(typeof(IntegrationServicesProjectServiceModule).Assembly, opts =>
                    {
                        opts.RemoteServiceName = "ProjectService";
                        opts.RootPath = "project";
                    });
            });
        }
    
        private static void ConfigureSwaggerUI(SwaggerUIOptions options, IConfiguration configuration)
        {
            options.SwaggerEndpoint("/swagger/v1/swagger.json", "ProjectService API");
            options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
            options.OAuthScopes("ProjectService");
        }
    
        private static bool IsSwaggerEnabled(IConfiguration configuration)
        {
            return bool.Parse(configuration["Swagger:IsEnabled"] ?? "true");
        }
    
        private void ConfigureDynamicClaims(ServiceConfigurationContext context)
        {
            context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
            {
                options.IsDynamicClaimsEnabled = true;
            });
        }
    }
    

    Please let me know what I need to do to get past this error.

    Thanks,

    Suresh

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a test project to reproduce your problem?

    Thanks

    liming.ma@volosoft.com

  • User Avatar
    0
    suresht created

    hi

    Can you share a test project to reproduce your problem?

    Thanks

    liming.ma@volosoft.com

    Hi maliming,

    Due to the size of the sample solution, I shared a OneDrive link for the code for your review.

    I was able to get past the error from yesterday but now I am getting the following error:

    Autofac.Core.DependencyResolutionException: An exception was thrown while activating Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator -> λ:Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions -> Microsoft.Extensions.Options.UnnamedOptionsManager`1[[Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions, Swashbuckle.AspNetCore.SwaggerGen, Version=6.5.0.0, Culture=neutral, PublicKeyToken=d84d99fb0135530a]] -> Microsoft.Extensions.Options.OptionsFactory`1[[Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions, Swashbuckle.AspNetCore.SwaggerGen, Version=6.5.0.0, Culture=neutral, PublicKeyToken=d84d99fb0135530a]] -> λ:Microsoft.Extensions.Options.IConfigureOptions`1[[Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions, Swashbuckle.AspNetCore.SwaggerGen, Version=6.5.0.0, Culture=neutral, PublicKeyToken=d84d99fb0135530a]][] -> Swashbuckle.AspNetCore.SwaggerGen.ConfigureSwaggerGeneratorOptions.
     ---> Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptions`1[Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions], System.IServiceProvider, Microsoft.AspNetCore.Hosting.IWebHostEnvironment)' on type 'ConfigureSwaggerGeneratorOptions'.
     ---> System.ArgumentException: An item with the same key has already been added. Key: Volo.Abp.Content.RemoteStreamContent
       at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
       at Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType(SwaggerGenOptions swaggerGenOptions, Type type, Func`1 schemaFactory)
       at Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.MapType[T](SwaggerGenOptions swaggerGenOptions, Func`1 schemaFactory)
       at Microsoft.Extensions.DependencyInjection.AbpSwaggerGenServiceCollectionExtensions.<>c__DisplayClass0_0.<AddAbpSwaggerGen>b__0(SwaggerGenOptions options)
       at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
       at Microsoft.Extensions.Options.UnnamedOptionsManager`1.get_Value()
       at lambda_method3(Closure, Object[])
       at Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate()
       --- End of inner exception stack trace ---
       at Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate()
       at Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass14_0.<UseSingleConstructorActivation>b__0(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context)
       at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context)
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       --- End of inner exception stack trace ---
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context)
       at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext context)
       at Autofac.Core.Resolving.Middleware.RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context)
       at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context)
       at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context)
       at Autofac.Extensions.DependencyInjection.KeyedServiceMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext context)
       at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext context)
       at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest& request)
       at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest& request)
       at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest& request)
       at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest& request)
       at Autofac.Core.Lifetime.LifetimeScope.Autofac.IComponentContext.ResolveComponent(ResolveRequest& request)
       at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
       at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters)
       at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
       at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType)
       at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetService(Type serviceType)
       at lambda_method1243(Closure, Object, HttpContext, IServiceProvider)
       at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
       at Volo.Abp.AspNetCore.Security.Claims.AbpClaimsMapMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
       at Prometheus.HttpMetrics.HttpRequestDurationMiddleware.Invoke(HttpContext context)
       at Prometheus.HttpMetrics.HttpRequestCountMiddleware.Invoke(HttpContext context)
       at Prometheus.HttpMetrics.HttpInProgressMiddleware.Invoke(HttpContext context)
       at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
       at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
    

    Please let me know if you need any other information from my side.

    Thanks,

    Suresh

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    If you call the AddAbpSwaggerGenWithOAuth method. it will call the AddAbpSwaggerGen as well. so you don't need to call AddAbpSwaggerGen again. it will cause the exception.

  • User Avatar
    0
    suresht created

    Hi maliming,

    Thanks for your valuable diagnosis. Your recommended suggestion fixed the issue!

    Thanks again,

    Suresh

Made with ❤️ on ABP v9.1.0-preview. Updated on October 22, 2024, 09:35