Hello, I have a problem.
Volo.Abp.AbpInitializationException: An error occurred during ConfigureServicesAsync phase of the module HitFrame.SaasService.SaasServiceHttpApiHostModule, HitFrame.SaasService.HttpApi.Host, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Extensions.DependencyInjection.AbpSwaggerGenServiceCollectionExtensions.AddAbpSwaggerGenWithOAuth(IServiceCollection services, String authority, Dictionary`2 scopes, Action`1 setupAction, String authorizationEndpoint, String tokenEndpoint)
at HitFrame.Shared.Hosting.AspNetCore.SwaggerConfigurationHelper.ConfigureWithAuth(ServiceConfigurationContext context, String authority, Dictionary`2 scopes, String apiTitle, String apiVersion, String apiName) in C:\Users\hitsoftdevadm18\Desktop\atlassian-bitbucket-pipelines-runner\temp\79132501-1037-5832-acea-3435bd03b6a5\1715608337513\build\shared\HitFrame.Shared.Hosting.AspNetCore\SwaggerConfigurationHelper.cs:line 40
at HitFrame.SaasService.SaasServiceHttpApiHostModule.ConfigureServices(ServiceConfigurationContext context) in C:\Users\hitsoftdevadm18\Desktop\atlassian-bitbucket-pipelines-runner\temp\79132501-1037-5832-acea-3435bd03b6a5\1715608337513\build\services\saas\src\HitFrame.SaasService.HttpApi.Host\SaasServiceHttpApiHostModule.cs:line 39
at Volo.Abp.Modularity.AbpModule.ConfigureServicesAsync(ServiceConfigurationContext context)
at Volo.Abp.AbpApplicationBase.ConfigureServicesAsync()
--- End of inner exception stack trace ---
at Volo.Abp.AbpApplicationBase.ConfigureServicesAsync()
at Volo.Abp.AbpApplicationFactory.CreateAsync[TStartupModule](IServiceCollection services, Action`1 optionsAction)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionApplicationExtensions.AddApplicationAsync[TStartupModule](IServiceCollection services, Action`1 optionsAction)
at Microsoft.Extensions.DependencyInjection.WebApplicationBuilderExtensions.AddApplicationAsync[TStartupModule](WebApplicationBuilder builder, Action`1 optionsAction)
The code block:
public override void ConfigureServices(ServiceConfigurationContext context)
{
// Enable if you need these
// var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
context.Services.AddAbpDbContext<SaasServiceDbContext>();
JwtBearerConfigurationHelper.Configure(context, "SaasService");
SwaggerConfigurationHelper.ConfigureWithAuth(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */ {
{ "SaasService", "Saas Service API" }
},
apiTitle: "Saas Service API"
);
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
ConfigureHealthChecks(context);
}
And;
public static void ConfigureWithAuth(
ServiceConfigurationContext context,
string authority,
Dictionary<string, string> scopes,
string apiTitle,
string apiVersion = "v1",
string apiName = "v1"
)
{
context.Services.AddAbpSwaggerGenWithOAuth(
authority: authority,
scopes: scopes,
options =>
{
options.SwaggerDoc(apiName, new OpenApiInfo { Title = apiTitle, Version = apiVersion });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
options.ResolveConflictingActions(apiDesc => apiDesc.First());
});
}