1

Simple question... I want to use Ninject Interceptors to take care of my NFRs, however alot of my classes require arguments in the constructors. I read that they are looking at allowing constructors with arguments but currently I get an error:

Can not instantiate proxy of class: myClass
Could not find a parameterless constructor.
Parameter name: constructorArguments

I am using version 2.2.1 I think, noticed there is a tagged 2.3 version on the extensions site, but will any of this solve my problems? if not is there any way around this?

somemvcperson
  • 1,263
  • 2
  • 18
  • 31

1 Answers1

0

2.3 adds support for Interface proxies. This means it will solve the problem for all types that are resolved by interface. It's also planned to add support for classes without default constructor.

But be aware that 2.3 is work in progress. While there aren't any known new problems it is not tested yet against real applications as 2.2 is and interface changes of new stuff can still change. Also InRequestScope support for XML and Conventions has temporarily been disabled.

Remo Gloor
  • 32,665
  • 4
  • 68
  • 98
  • That sounds fine, most of my items are bound via interfaces... thanks alot for the quick response! – somemvcperson Jun 21 '11 at 17:23
  • @remo-gloor Just gone to the team city build server and got the latest .net 4 version of the interceptor, and that wanted the latest ninject, so went and go that. However then Ninject.Web.Mvc complained that it couldnt find ninject 2.2, so updated that and now it cant find NinjectHttpApplication... am i being a muppet or is there some problem? – somemvcperson Jun 22 '11 at 15:41
  • Web has changed a bit. You have to get Ninject.Web.Common 2.3 – Remo Gloor Jun 22 '11 at 16:10
  • Thanks, got that now, will give it all a whirl! – somemvcperson Jun 22 '11 at 16:39
  • @remo-gloor Still getting the error... my binding looks something like: Bind>().To() should I be using the castle proxy or the linfu one? I was under the impression that linfu was more for silverlight... – somemvcperson Jun 22 '11 at 18:05
  • Some tests I performed showed that it is working properly with both LinFu and DP2. Be aware that you still will need to provide bindings for the dependencies of the intercepted class. – Remo Gloor Jun 23 '11 at 22:16
  • Would it be possible to elaborate on this answer a little more? Maybe a example on your blog, or a link or something? I know I am commenting on an old post, but I cant seem to find any information on how to pass arguments to the interceptor. I pushed to use Ninject instead of postsharp because I think it is a better solution, but if I cant figure out how to get this to work I will have to revert, which I really dont want to do! – Brandon Aug 21 '13 at 14:01