Tag Archives: ASP.NET Core

[Solved] Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Failed to generate Operation

Error Messages:
ErrorMessage: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Failed to generate Operation for action - PMToolkit.API.Controllers.ReportController.GetOrderReportFilesList (PMToolkit.API). See inner exception\r\n ---\u003E Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Failed to generate schema for type - System.Collections.Generic.IEnumerable\u00601[PMToolkit.API.Database.Models.OrderReportFile]. See inner exception\r\n ---\u003E System.InvalidOperationException: Can\u0027t use schemaId \u0022$OrderOption\u0022 for type \u0022$PMToolkit.API.Database.OrderOption\u0022. The same schemaId is already used for type \u0022$PMToolkit.API.Controllers.DelayOrdersController\u002BOrderOption\u0022\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository.RegisterType(Type type, String schemaId)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateReferencedSchema(DataContract dataContract, SchemaRepository schemaRepository, Func\u00601 definitionFactory)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateConcreteSchema(DataContract dataContract, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchemaForMember(Type modelType, SchemaRepository schemaRepository, MemberInfo memberInfo, DataProperty dataProperty)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.CreateObjectSchema(DataContract dataContract, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.\u003C\u003Ec__DisplayClass10_0.\u003CGenerateConcreteSchema\u003Eb__3()\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateReferencedSchema(DataContract dataContract, SchemaRepository schemaRepository, Func\u00601 definitionFactory)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateConcreteSchema(DataContract dataContract, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchemaForType(Type modelType, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchema(Type modelType, SchemaRepository schemaRepository, MemberInfo memberInfo, ParameterInfo parameterInfo)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.CreateArraySchema(DataContract dataContract, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.\u003C\u003Ec__DisplayClass10_0.\u003CGenerateConcreteSchema\u003Eb__1()\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateConcreteSchema(DataContract dataContract, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchemaForType(Type modelType, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchema(Type modelType, SchemaRepository schemaRepository, MemberInfo memberInfo, ParameterInfo parameterInfo)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateSchema(Type type, SchemaRepository schemaRepository, PropertyInfo propertyInfo, ParameterInfo parameterInfo)\r\n   --- End of inner exception stack trace ---\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateSchema(Type type, SchemaRepository schemaRepository, PropertyInfo propertyInfo, ParameterInfo parameterInfo)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateResponseMediaType(ModelMetadata modelMetadata, SchemaRepository schemaRespository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.\u003C\u003Ec__DisplayClass19_0.\u003CGenerateResponse\u003Eb__2(String contentType)\r\n   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable\u00601 source, Func\u00602 keySelector, Func\u00602 elementSelector, IEqualityComparer\u00601 comparer)\r\n   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable\u00601 source, Func\u00602 keySelector, Func\u00602 elementSelector)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateResponse(ApiDescription apiDescription, SchemaRepository schemaRepository, String statusCode, ApiResponseType apiResponseType)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateResponses(ApiDescription apiDescription, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository)\r\n   --- End of inner exception stack trace ---\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable\u00601 apiDescriptions, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable\u00601 apiDescriptions, SchemaRepository schemaRepository)\r\n   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)\r\n   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)\r\n   at Steeltoe.Management.Endpoint.CloudFoundry.CloudFoundrySecurityMiddleware.Invoke(HttpContext context)\r\n   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context).

 

Solution:
You must add a swagger config as below:

services.ConfigureSwaggerGen(opt =>
{
	opt.CustomSchemaIds(x => x.FullName);
});

[Solved] Asp.Net Core IIS Error: HTTP Error 500.30 – ASP.NET Core app failed to start

The error message prompts you to check whether there is an error message in the system event log

check the event log and find

according to ASP Net core module – Microsoft docs shows that the default configuration is in-process hosting, which is set to inprocess. It shows that the specified web project is out of process hosting

Solution:
only the published web Change hostingmodel = “inprocess” in config file to hostingmodel = “outofprocess” or delete hostingmodel = “inprocess” directly.

Error: Unable to build IHost No DbContext named ‘PersistedGrantDbContext‘ was found.

IdentityServer4 data migration error: surprisingly Apollo appsettings.json configuration problem!

PM> dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb –project MicroService.IdentityServer
Build started…
Build succeeded.
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Unable to build IHost
No DbContext named ‘PersistedGrantDbContext’ was found.
PM> dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb –project MicroService.IdentityServer