Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Dependency Injection technique should I use in dotnet?

[Revision 5/14/09: I need this to target Dotnet 2.0 because of my deployment scenario]

I am new to Dependency Injection & IoC.

I see that there are a plethora of containers and libraries to help the process along.

What are the pros and cons of using these libraries. What is your favorite (dotnet) container and why?

What about rolling my own container for Dependency Injection?

Thanks,

Peter Stephens

like image 951
Peter Stephens Avatar asked Oct 19 '25 15:10

Peter Stephens


2 Answers

If you need only Dependency Injection probably AutoFac will be the best option, since it's small, quite simple and logical. It should not be to hard to grok.

Once you get that, and you feel the need for more mature product (that can do other things than simply DI) I'd suggest taking a look at Castle Windsor, which is pretty powerful out of the box, very well designed, and customizable. If you don't like that, I've heard good things about StrcutureMap.

like image 169
Krzysztof Kozmic Avatar answered Oct 21 '25 05:10

Krzysztof Kozmic


Spring.Net

like image 45
treehouse Avatar answered Oct 21 '25 07:10

treehouse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!