Closed ekalchev closed 2 months ago
You have actually specified 3 different bindings here for Services.ServiceHost
:
// 1
.Bind<Services.ServiceHost>().As(Singleton).To<Services.ServiceHost>()
// 2
.Bind<IServiceHost>().To<Services.ServiceHost>()
// 3
.Bind<IApplicationLifecycleManager>().To<Services.ServiceHost>()
But I assume you only wanted one:
.Bind<Services.ServiceHost, IApplicationLifecycleManager, IServiceHost>().As(Singleton).To<Services.ServiceHost>()
Or even simpler:
.Bind().As(Singleton).To<Services.ServiceHost>()
Thanks that worked!
@ekalchev I saw that you are trying to use Func with arguments. Perhaps this example will help you :)
I expect with the registration below to share the same instance of ServiceHost when resolving IServiceHost and IApplicationLifecycleManager. However I can see that two instances are created.
If I change the last two lines to
It seems to be working as expected