You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
I am using Castle.Windsor.MsDependencyInjection with Microsoft.Extensions.Hosting HostBuilder. When the host is terminated the Windsor container is not disposed and the application fails to shutdown.
@hikalkan Did you ever find a solution to this? I am having the same issue. I see the IDisposable proposal was rejected, but that still leaves an issue of the Windsor container not being disposed of properly.
I solved this problem by creating a hosted service to manage the lifetime of the container. The container gets disposed on the ApplicationStopped event.
Inject the IHostApplicationLifetime (formerly IApplicationLifetime) service into any class to handle post-startup and graceful shutdown tasks. Three properties on the interface are cancellation tokens used to register app start and app stop event handler methods. The interface also includes a StopApplication method.
Description
I am using
Castle.Windsor.MsDependencyInjection
withMicrosoft.Extensions.Hosting
HostBuilder. When the host is terminated the Windsor container is not disposed and the application fails to shutdown.Proposed Solution
The following code changes resolve the issue
Make
ScopedWindsorServiceProvider
implement IDisposableDependencies
Microsoft.Extensions.Hosting 2.2
Castle.Windsor.MsDependencyInjection 3.3.1
The text was updated successfully, but these errors were encountered: