Microsoft Embraces Dependency Injection in the Framework

| by Jonathan Allen Follow 632 Followers on Apr 28, 2008. Estimated reading time: less than one minute |

In order to reduce duplication across frameworks like WCF, WPF, and ASP.NET, Microsoft has formed the Application Framework Core team. The goal of this team is to prevent design issues like the different dependency property systems for WPF and WF.

One of their first projects is the Managed Extensibility Framework or MEF. This project will leverage techniques such as Naming and Activation Services, Dependency Injection, and Duck Typing. Much of the work underlying Microsoft's implementation is based on community feedback. Krzysztof Cwalina writes,

The direct engagement with the DI community is also starting. We gave a talk on the technology at last week’s MVP Summit, and talked with Jeremy Miller (the owner of Structure Map) and Ayende Rahien (Rhino Mocks) . We got lots of great feedback from Jeremy and Ayende and I think their experience in the DI space and their feedback will be invaluable as the project evolves. Thanks guys! We are of course also looking forward to engaging others in the DI community.

While still in the early phases, some early examples of the syntax are available. In .NET tradition, it is based on attributes rather than XML or explicit object passing.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Other Resources by Al Tenhundfeld

If you're interested in this topic, I'd also read the earlier interview on Unity.

And some popular open source DI frameworks:

Ninject (new but looks very impressive)

Spring.Net (port of the very successful and established Java framework)

MS has used DI for quite a while by Jim Leonardo

MS has used DI as the core for configurability of the Enterprise Library for a long time now, so the real news here is that they're finally making it a focus for a product team rather than just the patterns and practices team. What's good to hear is the engagement with others.

ORM, DI, all of this stuff made popular in Java long long ago. by serge ----

A technique that has long existed in the java world and has been the norm for some time now.

Where is Castle? by F Quednau

Should it not at least get honorable mention?

In my opinion I still cannot believe the way Microsoft treats extremely popular and successful Open Source Projects. It's all there guys, and we can embrace it NOW.

Re: Where is Castle? by Al Tenhundfeld

Why would you recommend Windsor Castle over Spring.NET? I have heard good things about Castle, but I've not taken the time to sit down and play with it.

Right now, I'm excited about Ninject. If you haven't looked at it, I recommend you do. In my opinion, if you all you want is an intuitive, usable IoC container, Ninject is far better than Spring.NET -- although I believe they're still working on the performance. I'd be very interested to hear your thoughts on Castle v Ninject also.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

5 Discuss