You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read in historical articles/tickets/posts that if you want to do proxying on classes you need to provide a parameterless constructor. I was just wondering is this still applicable, and if so is it a problem within the ninject layer or castle dynamic proxy layer?
As if I have a class like:
public class SomeClassToProxy
{
public SomeClasstoProxy(ISomething something) { ... }
[SomeInterceptAttribute]
public virtual DoSomething() { ... }
}
And lets assume somewhere I have Bind<ISomething>().To<Something>();, so the DI framework knows about the ISomething and how to resolve it, so when it says it needs a parameterless constructor I am unsure why it causes a problem when I am binding against the class opposed to the interface, as even if I proxy against an interface (i.e. public class SomeClassToProxy : ISomeInterfaceToProxy) and have the binding at the interface layer it still needs to resolve the SomeClassToProxy at some point.
Anyway some info around this issue would be great as atm the moment we try to put any intercept attributes on an ApiController DynamicProxy blows up because it cannot find a parameterless constructor.
The text was updated successfully, but these errors were encountered:
For this I used the Ninject.Web.WebApi or if you do MVC its in the Ninject.Web.MVC package. There is a syntax I have used to put ActionFilters on Controllers when an Attribute exists. To do this I put these lines in with my Bindings that execute on start.
In my case my Filters Inherited from one of these System.Web.Mvc.IAuthorizationFilter, System.Web.Http.Filters.IAuthorizationFilter depending on whether the filter is for WebAPI or MVC
I have read in historical articles/tickets/posts that if you want to do proxying on classes you need to provide a parameterless constructor. I was just wondering is this still applicable, and if so is it a problem within the ninject layer or castle dynamic proxy layer?
As if I have a class like:
And lets assume somewhere I have
Bind<ISomething>().To<Something>();
, so the DI framework knows about theISomething
and how to resolve it, so when it says it needs a parameterless constructor I am unsure why it causes a problem when I am binding against the class opposed to the interface, as even if I proxy against an interface (i.e.public class SomeClassToProxy : ISomeInterfaceToProxy
) and have the binding at the interface layer it still needs to resolve theSomeClassToProxy
at some point.Anyway some info around this issue would be great as atm the moment we try to put any intercept attributes on an
ApiController
DynamicProxy blows up because it cannot find a parameterless constructor.The text was updated successfully, but these errors were encountered: