I have inherited this project, I normally do not unity as my dependency resolver, so forgive me if this is a dumb question.
I am getting he following message when I try and resolve a interface.
Inner Exception 1:
InvalidOperationException: No public constructor is available for type [ProjectName].ITest
Inner Exception 2:
InvalidRegistrationException: Exception of type 'Unity.Exceptions.InvalidRegistrationException' was thrown.
Now before anyone jumps on me and says I have no constructor the class looks like this... it has a constructor with no parameters.
namespace ProjectName
{
public class Test : ITest
{
public Test()
{
}
public int Foo() => 99;
}
public interface ITest
{
int Foo();
}
}
So there is a constructor that has no parameters This is the class that is trying to resolve the class.
[Route("api/Test")]
public class TestController : ApiController
{
[Dependency]
public ITest Test { get; set; }
public TestController()
{
}
[HttpPost]
public IHttpActionResult Post()
{
var i = Test.Foo();
return Ok();
}
}