0
votes

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

public class  MyClass

{

    public MyClass(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?

1
Not sure if this is just an issue with how you pasted your code into SO, but in your code the parameter name is parmList and in your config its: paraList...BFree

1 Answers

0
votes

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.