Swashbuckle.AspNetCore icon indicating copy to clipboard operation
Swashbuckle.AspNetCore copied to clipboard

6.3.1 Swashbuckle.AspNetCore.Cli Instances cannot be resolved and nested lifetimes cannot be created exception

Open slnkykrn opened this issue 2 years ago • 4 comments

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.

image

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 : image

Can you help us about this issue ? Thank you.

slnkykrn avatar Jun 28 '22 07:06 slnkykrn

Is there any idea ? Thank you

slnkykrn avatar Jul 25 '22 06:07 slnkykrn

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?

homemdasneves avatar Sep 17 '22 18:09 homemdasneves

This did the trick: https://github.com/domaindrivendev/Swashbuckle.AspNetCore#use-the-cli-tool-with-a-custom-host-configuration

homemdasneves avatar Sep 17 '22 19:09 homemdasneves

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.

github-actions[bot] avatar Apr 21 '24 01:04 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 05 '24 01:05 github-actions[bot]