Error occurred when trying to create a controller of type 'EmployeeController'. Make sure controller has a parameterless public constructor
Buried in the stack trace is the root cause of the issue:
InvalidOperationException - The current type, BusinessServices.IEmployeeServices, is an interface and cannot be constructed. Are you missing a type mapping? ----------------------------------------------- At the time of the exception, the container was: Resolving TheWork.Controllers.EmployeeController,(none) Resolving parameter "employeeServices" of constructor TheWork.Controllers.EmployeeController(BusinessServices.IEmployeeServices employeeServices) Resolving BusinessServices.IEmployeeServices,(none) Microsoft.Practices.Unity.ResolutionFailedException at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable1 resolverOverrides)
The issue is that the EmployeeController
requires an instance of IEmployeeServices
but Unity does not know what concrete type to instantiate. It looks like the implementation class is supposed to be registered by the call to ComponentLoader.LoadContainer(container, ".\\bin", "BusinessServices.dll");
but for some reason it is not being registered. It could be a bug in that code or perhaps the BusinessServices.dll is out of date and does not contain the IEmployeeServices
definition.
It's hard to tell why IEmployeeServices
is not registered without seeing all the code and runtime dependencies (because types are being dynamically loaded/registered).