由网友(囍遇你。)分享简介:注入属性不工作的领域。 Inject attribute is not working for field. [Inject]public MyContext context; //Not injected[Inject]public MyContext context {get; set;} //Inject...
注入属性不工作的领域。
Inject attribute is not working for field.
[Inject]
public MyContext context; //Not injected
[Inject]
public MyContext context {get; set;} //Injected
我使用的默认Ninject设置。为什么字段不注入?
I am using default Ninject settings. Why field is not injected ?
推荐答案
由于这是不允许的。
从Ninject 2 Beta版公告:
From the Ninject 2 Beta announcement:
的事情,是在Ninject 1.x中的 不在Ninject 2:
Things that were in Ninject 1.x that are not in Ninject 2: 字段注入:Ninject 2的 注射现在由前pression驱动 树木,并在.NET 3.5也没办法 用一个前pression设置字段值 树。由于这是一个不好的做法 反正,我决定削减它。 Field injection: Ninject 2’s injection is now driven by expression trees, and in .NET 3.5 there is no way to set field values with an expression tree. Since this is a bad practice anyway, I decided to cut it.
相关推荐
最新文章