Closed GoogleCodeExporter closed 8 years ago
I just verified that this exception also gets thrown if I explicitly register
MyComponent using ResolveOptional to resolve the HttpContextBase. I would
expect a null from ResolveOptional in that case.
Original comment by frustrat...@gmail.com
on 23 Feb 2011 at 5:14
Thanks for getting in touch, apologies about the slow response.
The Autofac behavior in this case is by design; we follow one general principle
that a component is never "hidden" because of missing dependencies or invalid
scope. Although it is a hindrance in this scenario, it makes many others much
more predictable and easy to debug.
In this case I think the best option is to create two components, one wrapping
the WCF context and the other wrapping the HTTP context.
Register the WCF one by default, then use the overloaded constructor of
AutofacDependencyResolver to override the WCF one with the HTTP one by
registering it on a per-request basis.
Hope this helps!
Cheers,
Nick
Original comment by nicholas...@gmail.com
on 9 Mar 2011 at 9:30
Original issue reported on code.google.com by
frustrat...@gmail.com
on 23 Feb 2011 at 5:06