Closed JornWildt closed 8 years ago
Here is an example showing the problem.
For a working version, exclude the IDependencyResolverAccessor implementation of the Configuration class. For a non working version, include it.
Hi Jorn,
Have you tried the suggestion in the readme? https://github.com/openrasta/openrasta-castle-windsor/blob/master/README.md
//Register stubs to stop Windsor complaining
_windsorContainer.Register(
Component.For<HttpContext>().UsingFactoryMethod(() => (HttpContext)null),
Component.For<AspNetRequest>().UsingFactoryMethod(() => (AspNetRequest)null),
Component.For<AspNetResponse>().UsingFactoryMethod(() => (AspNetResponse)null));
It is due to a change in the newer version of Castle Windsor, we currently have a that work around. As we would have to rewrite the castle windsor intergration otherwise.
Here is what your config should look like: https://gist.github.com/holytshirt/bcbd85a9ce2bd41481c2ddadda672c03
Let me know it this solves you problem.
That looks like the thing I am missing. I'll try it ASAP and close the issue if it works.
Registering the stubs as sugested worked like a charm. Thanks.
That integration must die.
I have the simplest possible setup with one handler and one resource. It works "out of the box" with OpenRasta but as soon as I start using the Castle Windsor container it fails.
The log output is:
With some debugging it turns out that WindsorDependencyResolver throws exceptions when calling ResolveAllCore for IOperationFilter which in turn means no operations are found.
The output from Castle is:
So for some reason it cannot get an instance of IRequest as AspNetRequest since AspNetRequest depends on System.Web.HttpContext which is not added to the container.
AspNetRequest has the following constructor:
So it does unfortunately depend on HttpContext which is not expected to be added to the container.
But AspNetRequest is added as an instance to the container so it should in principle not be an issue. Unfortunately Windsor insists on looking for the dependencies even if the component is added as an instance.
The solution seems to be to register the instances differently in the Windsor container?