Skip to content

class proxy (apicontroller) and constructor args #38

@grofit

Description

@grofit

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions