开发者

@Enterprise Library Unity, How to inject to the List Property

The follows is my code snippet, and I want to deliver the List parameter to my construct.

public class  MyClass

{

    public MyCla开发者_运维知识库ss(List<string> parmList)
    {
         this.MyList=parmList;
    }

    public List<string> MyList
    {
        get;set;
    }


}

The config:

  <alias alias="List" type="System.Collections.Generic.List[[System.String, 

   mscorlib],mscorlib]"/>


  <register>


     <constructor>
        <param name="paraList" type="List" />
     </constructor>

  </register>

But when I resolve request to the container it throw out the exception:

The type List`1 has multiple constructors of length 1. Unable to disambiguate.

Is there any configuration error?


In order to resolve an instance of MyClass, Unity must Resolve an instance of List<string> to pass to your constructor - but it is unable to choose among the available constructors for List<string>. Here is some information on telling Unity which constructors to use when initializing a class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜