Injection of class with multiple constructors

Posted by Jax on Stack Overflow See other posts from Stack Overflow or by Jax
Published on 2010-03-26T09:42:33Z Indexed on 2010/03/26 9:53 UTC
Read the original article Hit count: 248

Filed under:

Resolving a class that has multiple constructors with NInject doesn't seem to work.

public class Class1 : IClass
{
public Class1(int param) {...}
public Class1(int param2, string param3) { .. }
}

the following doesn’t seem to work:

IClass1 instance =
    IocContainer.Get<IClass>(With.Parameters.ConstructorArgument(“param”, 1));

The hook in the module is simple, and worked before I added the extra constructor: Bind().To();

Thanks in advance...

© Stack Overflow or respective owner

Related posts about ninject