c# - Lazy<> Ninject Injection -


i use ninject framework. in code have lazy object. can create instance, when call value property got exception.

 private lazy<ipsoriasisreportusercontrol> psoriasisreportusercontrol;  [inject]     public lazy<ipsoriasisreportusercontrol> psoriasisreportusercontrol     {         { return psoriasisreportusercontrol; }         set { psoriasisreportusercontrol = value; }     } 

i got

the lazily-initialized type not have public, parameterless constructor

exception because injection not inject method constructor. think have write method bind creates new instance.

use factory extension ninject https://github.com/ninject/ninject.extensions.factory


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -