Question

How do you inject mutiple param using ninject? example:

IWeapon weap;
ISheild sheld;
ISoap isoap;
public myclass(IWeapon weapon, IShield shield, ISoap soap)
{
    weap = weapon;
    sheld = shield;
    isoap = soap;
}

already tried this it gave me a ninject activation exception all I did to bind them was to use

kernel.Bind<IWeapon>().To<Sword>();
kernel.Bind<IShield>().To<DragonSheild>();
kernel.Bind<ISoap>().To<Safeguard>();

I cannot run my project it keeps giving me a ninject exception.

No correct solution

OTHER TIPS

The example you gave is not from your application right? I think your application looks like this:

public class TerminalService : ITerminalService
{
  public TerminalService(IPOSJobService posJobService){}
}

public class POSJobService : IPOSJobService
{
  public class POSJobService(ITerminalService terminalsService){}
}

If it's true then the problem is clear. The two class has cross reference each other.
It's some kind a parent-child relation, but the dependency should be one way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top