的整數我有如下因素類注入與Ninject
public class Foo
{
public Foo(int max=2000){...}
}
,我想用Ninject注入一個恆定值到富。我也試試這個
Bind<Foo>().ToSelft().WithConstructorArgument("max", 1000);
,但我得到以下錯誤,當我嘗試使用_ninject.Get<Foo>
:
Error activating int
No matching bindings are available, and the type is not self-bindable.
Activation path:
3) Injection of dependency int into parameter max of constructor of type Foo
是否有您使用的是特殊的理由自我約束?我剛剛嘗試過這一點,並得到同樣的錯誤。 – mdm 2011-05-27 15:18:42