Click here to Skip to main content
15,881,757 members
Articles / Programming Languages / C#
Tip/Trick

Generic Method Problem in Unity Dependency Injection Container

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
8 Mar 2011CPOL 37.2K   2   4
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)


Written By
Software Developer (Senior) Vizrt Bangladesh
Bangladesh Bangladesh
I am truly versatile and 360 degree Engineer having wide range of development experience in .NET and Java Platform. I am also proficient in system level programming in C++. To me technology is not at all a problem, it’s the client requirement that matters! That is I am ready and comfortable to use any technology to make the business of my client a success.

In my five years of experience I have the opportunities to work for fortune 500 companies of US and many renowned clients from Europe.

My Linkedin Profile: http://bd.linkedin.com/in/mahmudazad

Comments and Discussions

 
Answerthanks for nice help Pin
Ashok Verma19857-Aug-15 6:01
Ashok Verma19857-Aug-15 6:01 
GeneralThanks Man! Pin
brain tees19-Nov-14 2:49
brain tees19-Nov-14 2:49 
GeneralReason for my vote of 5 Nice tip buddy.... You nailed it.. Pin
Pravin Patil, Mumbai7-Mar-11 20:12
Pravin Patil, Mumbai7-Mar-11 20:12 
GeneralRe: Thank you! :) Pin
Mahmudul Haque Azad7-Mar-11 22:06
Mahmudul Haque Azad7-Mar-11 22:06 
Thank you! Smile | :)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.