Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint


It may seem strange to wait until later in the chapter to discuss extensibility when it is a fundamental part of the framework. It is important to understand those other features in order to take full advantage of the extensibility model that MEF provides, because it is managed directly through parts within catalogs. Everything you’ve learned so far about discovery and lifetime management also applies to the code you integrate when you build extensibility into your application.

Case Studies: MEF in the Real World

I began working with MEF very early when it was being released as a “preview.” One of the first projects that took advantage of it was the 2010 Vancouver Winter Olympics. Microsoft hired our company to build software that would help them manage their farm of dedicated servers for streaming live and on-demand video content. It was important to build the project in a flexible and extensible manner because we knew the deadline couldn’t be missed.

One key feature we built was a monitoring service that compared replication servers against each other. The backend would produce an XML document illustrating the differences between the servers so the support staff could react to issues proactively before a server had to fail over. The team still had not decided their preferred way to have their reports delivered.

MEF made it an easy problem to solve. We simply defined a contract for receiving the document and parsing it and then wrote a default parser that formatted the output to a CSV document that could be opened in Excel.

When it was decided that it should be parsed into a text document and emailed, we simply built the module to implement the interface, exported it, and dropped it in the target directory. MEF allowed the host service to automatically pick up the extension and begin sending emails immediately. We did not have to modify or reinstall the service.

Another powerful example of using MEF was for a different Microsoft project that involved social media. Our company was hired to build an analytics dashboard that would allow users to specify brands and campaigns with sets of keywords and then monitor Twitter, Flickr, YouTube, and other social media outlets for comments and discussions relating to the keywords.

An artificial intelligence engine analyzed the text and would assign a sentiment to the information to provide an aggregate trend of whether the keyword was receiving positive or negative feedback.

The project involved many different modules that covered areas such as configuration, monitoring, responding to comments and tweets, data visualization, and task management. MEF allowed us to divide the project into discreet, independent modules that could be developed, tested, and deployed in parallel.

When Microsoft needed new items to be added, we simply built the new module and tagged it with the export attribute. The main application would automatically pick up the new module, integrate it into navigation, and load the extension at runtime.

The success of these projects led me to develop a framework called Jounce, which will be discussed later in this chapter. Jounce is an MVVM framework that uses the MEF to handle most of the concerns around discovery, lifetime management, and extensibility. Jounce has subsequently been used as the main foundation for many of the Silverlight applications we’ve written for customers.

One project that had a particularly important impact was the slate application we developed for Rooms to Go. You can watch a video with details of the case study here:

Jounce allowed us to quickly and efficiently put the application together, but more importantly MEF enabled us to work side by side with the Rooms to Go development team. When they had new modules to add, it was simple and straightforward for them to build and extend the application with their own functionality.


You are currently reading a PREVIEW of this book.


Get instant access to over $1 million worth of books and videos.


Start a Free Trial

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint