Last post Jun 18, 2015 10:29 PM by Krunal Parekh
Jun 17, 2015 04:05 PM|mahens|LINK
We are using Unity container has dependency injection in our code. We have followed below link
But when GetService(Type
serviceType ) is called, some of the type doesn't loads and throws exception like"
Resolution of the dependency failed, type = "System.Net.Http.Formatting.IContentNegotiator", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, System.Net.Http.Formatting.IContentNegotiator, is an interface and cannot be constructed. Are you missing a type mapping?
Has any one faced same issue with WEB API and unity container dependency resolver?
Jun 18, 2015 10:29 PM|Krunal Parekh|LINK
Please see :
http://stackoverflow.com/questions/24114970/web-api-start-up-exceptions-with-idependencyresolver-implimentation this might helps.
Here is a working sample (Sample Demo) make sure you add the configuration and register the repositories
properly as described in the article.
var container = new UnityContainer();
container.RegisterType<IProductRepository, ProductRepository>(new HierarchicalLifetimeManager());
config.DependencyResolver = new UnityResolver(container);