Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)

Blogs

Mike Taulty's Blog

Elsewhere

Archives

One of the interesting things about Silverlight 4 is the inclusion of the Managed Extensibility Framework (MEF) and I think it really helps to build the case for Silverlight 4 as a great platform for business applications.

Silverlight applications are rich internet applications – the deployment model is strongly angled towards web deployment as the only way to install a Silverlight application is to start on a web page and run the application - the deployment is intended to be simple, quick and secure.

As developers build more and increasingly complex applications with Silverlight they can hit a tension between preserving the ethos of Silverlight deployment ( i.e. simple, quick and secure ) and building an application with the rich set of functionality that they need.

They also have to contend with the usual “abilities” of software development like making sure that the application is correct, performant, available, secure, scalable, maintainable and possibly extensible whilst being productive with the code they write.

MEF is one framework that can help in that it simplifies the design of extensible applications and components. It can flexibly and dynamically discover a set of loosely coupled components and analyse their dependencies in order to compose them together at run time.

MEF labels components as composable parts. A composable part is a component that defines ( somehow, MEF is not prescriptive here );

  • imports – a set of functionality that it needs ( or might at the least would like ) to have
  • exports – functionality that it provides

MEF provides a composition container which is a type that knows how to analyse a set of composable parts to determine which imports/exports can be satisfied in order to tie the componentry together without those parts or any other code necessarily having to come along up-front and introduce or register themselves.

The composition container is very flexible in terms of how composable parts can be introduced into it and one mechanism uses an extensible framework for discovery of parts including ( in Silverlight 4 Beta and the Silverlight 4 Toolkit ) components with the ability to dynamically download additional Silverlight XAPs at runtime and add them into an already running application.

If you’re building Silverlight applications, I think it’s important to get a view of what MEF can do for your application. I’ve been exploring MEF in the Silverlight 4 Beta and have made some screencasts as part of that exploration that ( hopefully! ) might speed up your own explorations. They’re hyperlinked below and I might add some more if time permits.

note – these videos are meant as a series to be chained together rather isolated one-off tutorials so you’ll get a better experience if you find time to watch them all rather than just the first one.

image

 image

 image

 image

 image

 image

and you can find them all ( and any new ones ) by going here;

http://channel9.msdn.com/tags/learnMEFSL4/

and subscribe to any stuff that I’m posting on Channel 9 by going here;

http://channel9.msdn.com/posts/mtaulty/RSS/


Posted Thu, Dec 31 2009 4:23 AM by mtaulty
Filed under: ,

Comments

uberVU - social comments wrote Social comments and analytics for this post
on Thu, Dec 31 2009 5:19 AM

This post was mentioned on Twitter by mtaulty: blog: Silverlight 4 and the Managed Extensibility Framework http://bit.ly/6CGNI7

Rachida Dukes wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Thu, Dec 31 2009 9:44 AM

Thank you so much for this wonderful tutorial.

Rachida

Glenn Block wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Thu, Dec 31 2009 1:27 PM

Mike, it's great to see these getting out there. The content is stellar, and there's nothing else like it out there today.

DotNetShoutout wrote Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF) - Mike Taulty
on Thu, Dec 31 2009 3:24 PM

Thank you for submitting this cool story - Trackback from DotNetShoutout

michaud wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Thu, Dec 31 2009 7:43 PM

One problem is multiple assemblies and, (ok two) how do i incorporate mvvm?

Tomasz Wisniewski wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Sat, Jan 2 2010 8:21 AM

Great contect - but I've already said that on twitter :) but also great wallpapers!

Mr. Magoo wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Mon, Jan 4 2010 3:31 PM

Mike, I just wanted to say thanks! Absolutely great tutorials, again thanks for taking the time and sharing the knowledge!

Cheers!

Sreeni.NET wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Fri, Jan 8 2010 4:50 PM

Hi Mike

thanks for your time and making this great video .  

Thanks

Sreeni

Phil Cockfield wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Thu, Feb 4 2010 12:20 PM

Hi Mike.  Thanks so much for these videos.  You're a gifted communicator.

I had a question about the PackageCatlog video (part 5).

The way you structured the application was to divide it up into the various class libraries AND create corresponding Package (SL Apps) which were really just there to tie various configurations of DLL's together.

I was wondering if that was a hard-n-fast best practice?  Would it also be sensible that if your application logic did cleave fairly readily around the XAP files, that you just create a set of SL-Apps (XAPs) and put the module's logic straight into that project (rather than seperate ClassLibrary assemblies)?

Many thanks.

Phil Cockfield wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Thu, Feb 4 2010 12:21 PM

Hi Mike.  Thanks so much for these videos.  You're a gifted communicator.

I had a question about the PackageCatlog video (part 5).

The way you structured the application was to divide it up into the various class libraries AND create corresponding Package (SL Apps) which were really just there to tie various configurations of DLL's together.

I was wondering if that was a hard-n-fast best practice?  Would it also be sensible that if your application logic did cleave fairly readily around the XAP files, that you just create a set of SL-Apps (XAPs) and put the module's logic straight into that project (rather than seperate ClassLibrary assemblies)?

Many thanks.

mtaulty wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Thu, Feb 4 2010 2:24 PM

Hi Phil,

Ah, interesting - I hadn't really thought too hard about this :-)

I wonder if it might be best to build class libraries because you can then reference those class libraries from multiple places (like test projects if necessary) and any configuration of XAPs whereas I don't think you can add a XAP as a reference?

Just my 2p - haven't necessarily given it a tonne of thought!

Mike.

Phil Cockfield wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Thu, Feb 4 2010 3:55 PM

Yeah right.  I thought that might be the case when I was watching your videos, but I've checked it out, and you can reference a "Silverlight Application" from a ClassLibrary, just as if it was a ClassLibrary.

So there doesn't seem to be any fundamental difference in cloth these different projects types are cut from, apart from one has an App.xaml and generates a XAP.

Ruslan Urban wrote re: Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF)
on Sat, Feb 13 2010 10:21 AM

UR right Phil. SL application is a dll with an application manifest XML file packaged into a zip file with file extension xap. The manifest file specifies entry point into the application, but the dll is pretty much the same format as a SL class library. The advantage of using an application project is that the compiled dll  can be copied into the ClientBin folder upon compile. However, a good practice is to remove App.xaml, and MainPage.xaml along with the cs files after you add a Silverlight Application to your solution.

BTW, you can convert a Class Library project into an application by adding a manifest file to the project and updating csproj file (just compare library and application csproj files to spot the differences).

iAwaaz-News-for-the-People-by-the-People wrote Silverlight 4 Screencasts - the Managed Extensibility Framework (MEF) - Mike Taulty
on Fri, Mar 5 2010 5:38 PM

Thank you for submitting this cool story - Trackback from iAwaaz-News-for-the-People-by-the-People

Mike Taulty's Blog wrote Experimenting with PRISM 4, Silverlight, MEF
on Wed, Aug 4 2010 1:06 PM

In the past I’ve made some screencast videos around PRISM or “Composite Application Guidance” for Silverlight