.net There should only be one applicable constructor的解决方案
这种情况一般是因为DI发现了多个构造函数导致的。可以在需要DI使用的构造函数上加上特性[ActivatorUtilitiesConstructor]
[ActivatorUtilitiesConstructor]
public Test(IA a)
{
}
public Test(IB b)
{
}
这样的话会选择上面那个构造函数
这种情况一般是因为DI发现了多个构造函数导致的。可以在需要DI使用的构造函数上加上特性[ActivatorUtilitiesConstructor]
[ActivatorUtilitiesConstructor]
public Test(IA a)
{
}
public Test(IB b)
{
}
这样的话会选择上面那个构造函数