Search code examples
ioc-containeraopninjectinterceptorcastle-dynamicproxy

Ninject: Possible to use injection constructor when type is being proxied for AoP?


I'm doing a project ground up using Ninject 2 and one question bugs me:

If you are to intercept methods on your type, you need to wrap it into proxy (castle dynamic proxy to be specific). Unless said type has a parameterless constructor, proxy creation fails. If it has, this constructor is being used when type instance is being resolved from the kernel.

Unfortunately, this means that my injection constructor with parameters is being neglected and I have to resort to property injection. I have some reluctance to couple my domain types with [Inject] attribute on properties.

Is there any way to use injection constructor with proxies for AoP using Ninject?


Solution

  • See http://groups.google.com/group/ninject/browse_thread/thread/27ecdf1aafc2ec07