Resolving classes without registering them using Castle Windsor

Windsor currently does not support that, and it’s by design. The reasoning is that you should explicitly register types you need so that you dont get misconfigured object.

There is however a possibility that there will be added a hook to create non-registered type at some point in the near future, as this is needed by the WCF integration facility. (Edit – it was added in v2.1 – take a look at ILazyComponentLoaders)

Anyway, regardless of lazy component loaders, the best you can do is to use fluent API to batch register all types from an assembly matching your needed criteria upfront. It’s not much more code and you’ll sleep better at nights.

Use lazy loaders only if you have really not enough information at startup (in your composition root) to determine what components you’ll need.

Leave a Comment