One of my class has 2 constructors:
public class Foo
{
public Foo() { }
public Foo(string bar) { }
}
When I am resolving this from unity, I get an exception because it looks for the string bar parameter. But I want the unity to instantiate this class using the constructor with no parameter. How can I achieve this?
I am using the LoadConfiguration method to register the types from the configuration file.
Unity Container Configuration:
container.LoadConfiguration("containerName");
Config File:
<unity xmlns="">
<typeAliases>
<typeAlias alias="string" type="System.String, mscorlib" />
<typeAlias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" />
</typeAliases>
<containers>
<container name="containerName">
<types>
<type type="IFoo, Assembly"
mapTo="Foo, Assembly" />
...
</types>
</container>
</containers>
</unity>