0
votes

I am working on implementing DI using Unity in Web API Layer. Following is the error message I am getting while calling the Service -

Resolution of the dependency failed, type = "API.Controllers.LeadController", name = "(none)".

Exception occurred while: while resolving.

Exception is: InvalidOperationException - The current type, Business.ILeadManager, is an interface and cannot be constructed. Are you missing a type mapping?


At the time of the exception, the container was:

Resolving API.Controllers.LeadController,(none)

Resolving parameter "leadManager" of constructor API.Controllers.LeadController(Business.ILeadManager leadManager)

Resolving Business.ILeadManager,(none)

Any suggestions, what is wrong ?

1

1 Answers

1
votes

Your unity configuration is missing a mapping for type Business.ILeadManager, so unity does not know which object instance it should create.

There should be an entry for your type like:

<register type="Business.ILeadManager" mapTo="MyLeadManagerImplementation" />