'Resolve Dependencies by a IWindsorContainer and a ILifetimeScope instance in Castle.Windsor 4.x
I have a (root-) IWindsorContainer / IKernel instance and a ILifetimeScope Instance.
How do I resolve dependencies from the IWindsorContainer/IKernel for the ILifetimeScope -instance manually (using the Resolve-operations)?
I have the requirement to create a service locator (I known it's bad) which is initialized to the scope of the ILifetimeScope.
More concretely, I have to take the ILifetimeScope from the HttpContext.Current.Items-collection of a MVC5 legacy application when it is attached and create a service locator which is used within some components during the executing of the request. The components call consequently SetConfigureAwait(false), which leads to null in HttpContext.Current ambient property and hence the windsor lifetime "per web request" is not available over the root IKernel/IWindsorContainer.
If there is an alternate and better way of accomplishing the requirement, I will also happily accept this solution.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
