Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Generic Method Problem in Unity Dependency Injection Container

5.00/5 (4 votes)
8 Mar 2011CPOL 38K   3  
Generic Method Problem in Unity Dependency Injection Container
This problem is related to Unity Application block (Dependency Injection container).
In some of my class files, I wanted to resolve my class by giving type name as usual
C#
Container.Resolve<idictionary><string,>>("somename");</idictionary>


But it was giving the following error.
The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' cannot be used with type arguments


I was banging my head on the wall as the same code is working which is written in some other class file.

After much investigation, I found that by adding a reference to unity like below solved the problem!
C#
using Microsoft.Practices.Unity; 


I got stuck in the mirage of extension methods! :((

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)