Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
6.3.1 Swashbuckle.AspNetCore.Cli Instances cannot be resolved and nested lifetimes cannot be created exception
Hello , We're using cli tool like below in our csproj .net 6 framework :
But we're getting an error like below , It depends on usage of Autofac I think.
When I add below code : We'll be getting an error this time
public class SwaggerHostFactory { public static IHost CreateHost() { return Program.CreateHostBuilder(new string[0]).Build(); } }
error after hostFactory :
Can you help us about this issue ? Thank you.
Is there any idea ? Thank you
I'm also facing this issue. I was having no problems at all until I added Hangfire to my project. I was able to narrow it down to this line (which adds the processing server as IHostedService):
services.AddHangfireServer();
If I remove it, the error goes away.
I don't need hangfire when I'm running the Swashbucle Cli, so a basic workaround in this specific case, would be to disable hangfire when running inside Cli. Does anybody know how to detect that?
This did the trick: https://github.com/domaindrivendev/Swashbuckle.AspNetCore#use-the-cli-tool-with-a-custom-host-configuration
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.
This issue was closed because it has been inactive for 14 days since being marked as stale.