Showing posts with label MEF. Show all posts
Showing posts with label MEF. Show all posts

Monday, April 21, 2014

Prism continues its Windows Desktop/WPF/MVVM Love with v5

Francis K. Cheung - Prism 5.0 for WPF just shipped.

Prism version 5.0 for WPF is now available. This version of Prism includes updates to existing and several new NuGet packages:

  1. Prism
  2. Prism.Composition (New)
  3. Prism.Interactivity (New)
  4. Prism.Mvvm (New)
  5. Prism.MefExtensions
  6. Prism.UnityExtensions

We’ve updated Prism 4.1 with bug fixes and a few new features. ...

Developer's Guide to Microsoft Prism Library 5.0 for WPF

April 2014

Prism provides guidance in the form of samples and documentation that help you easily design and build rich, flexible, and easily maintained Windows Presentation Foundation (WPF) desktop applications. Using design patterns that embody important architectural design principles, such as separation of concerns and loose coupling, Prism helps you to design and build applications using loosely coupled components that can evolve independently but which can be easily and seamlessly integrated into the overall application. In short, these applications are "built to last" and "built for change." These types of applications are known as composite applications.

This topic provides a brief overview of the Prism concepts with links to associated source code and documentation. If you are considering upgrading from Prism 4.1 to Prism 5.0 we include a "What’s New" and "Upgrading from Prism 4.1" topic that you should read.

...

...

image

What's New in Prism Library 5.0 for WPF

Prism 5.0 includes guidance in several new areas, resulting in new code in the Prism Library for WPF, new and updated QuickStarts, and updated documentation. Parts of the Prism Library changed between Prism 4.1 and Prism 5.0 to support the new guidance, fix existing issues, and respond to community requests.

...

New Guidance

Prism 5.0 contains several areas of new guidance as follows:

  • Prism.Mvvm is a portable class library that encapsulates Prism’s MVVM support. This library includes ViewModelLocationProvider. Views and view models can be wired up together using the new ViewModelLocationProvider’s convention-based approach as explained in Implementing the MVVM Pattern. View model construction can be accomplished using a dependency injection container. The ViewModel Locator’s extensibility points are discussed in Extending the Prism Library. DelegateCommands are now extendable and provide Async support. A new implementation of the INotifyPropertyChanged interface, the BindabaleBase class, was added.
  • The PopupWindowAction class was added to the Prism.Interactivity assembly to open a custom window in response to an interaction request being raised.
    The InvokeCommandAction action provided by Prism now passes trigger parameters to the associated command.
    For more information see Advanced MVVM Scenarios.
  • The EventAggregator classes have been moved to the Prism.PubSubEvents portable class library.
  • The NavigationParameters class can now be used to pass object parameters during navigation, using the overloads of the RequestNavigate method of a Region or RegionManager instance.

Changes in the Prism Library

Prism Library 5.0 includes changes related to new functionality, code organization, and APIs.

Code Organization

...

API Changes

...

Additions to the Prism Library Core API

The following namespaces were added to the Prism Library to support the new areas of guidance added in Prism 5.0:

  • Microsoft.Practices.Prism.PubSubEvents was added to help you send loosely coupled message using a portable class library.
  • Microsoft.Practices.Prism.Mvvm was added to assist you in implementing MVVM using a portable class library and several platform specific libraries.
  • Microsoft.Practices.Prism.SharedInterfaces has been added to share the IActiveAware interface between Prism and Prism.Mvvm assemblies, therefore the IActiveAware interface has been moved to this assembly. It is also intended for future use.

CodePlex Issues Resolved

  • ...

Example Code Changes

Prism 5.0 contains eleven separate code samples that demonstrate portions of the provided guidance. Several samples from Prism 4.1 were removed or replaced, and new samples added.

The following samples were added for Prism 5.0:

  • Basic MVVM QuickStart. This QuickStart shows a very simple MVVM application that uses the ViewModel Locator and show a parent and child ViewModels. For more information, see the MVVM QuickStart.
  • MVVM QuickStart. This QuickStart was removed for this version.
  • MVVM Reference Implementation. This reference implementation was removed for this version.
  • View-Switching Navigation QuickStart. This QuickStart now supports WPF. It demonstrates how to use the Prism region navigation API. For more information, see View-Switching Navigation QuickStart.
  • State-Based Navigation QuickStart. This QuickStart now supports WPF. It shows an approach that uses the Visual State Manager to define the views (states) and the allowed transitions. For more information, see State-Based Navigation QuickStart.
  • UI Composition QuickStart. This QuickStart now supports WPF. It replaced the View Injection QuickStart and the View Discovery QuickStart from Prism 2.0. In the current versions, both concepts are shown in one example application. For more information, see UI Composition QuickStart.
  • Interactivity QuickStart. This new QuickStart demonstrates how to exposes an interaction request to the view through the view model. The interactions can be a popup, confirmation, custom popup, and a more complex case where the popup needs a custom view model. It also shows Prism’s InvokeCommandAction action that passes the EventArgs from the trigger, as a command parameter. For more infromation, see Interactivity QuickStart.

NuGet Packages Now Available

In your application, you can now use NuGet to add references to the Prism assemblies. These packages include:

..."

Microsoft Downloads - Prism 5.0 for WPF – April 2014

Prism provides guidance designed to help you more easily design and build rich, flexible, and easy to maintain Windows Presentation Foundation (WPF) desktop applications.

...

MSDN Code Gallery - Getting Started Code Sample Using the Prism Library 5.0 for WPF

In this lab and associated sample, you will learn the basic concepts of modular application development using the Prism Library, and apply them to create a solution that you can use as the starting point for building a composite Windows Presentation Foundation (WPF) application. After completing this lab, you will be able to do the following:

  • You will create a new solution based on the Prism Library.
  • You will create and load a module.
  • You will create a view and show it in the shell window. 

This lab includes the following tasks:

...

MSDN Code Gallery - MVVM Code Sample using the Prism Library 5.0 for WPF

The Model-View-ViewModel (MVVM) QuickStart provides sample code that demonstrates how to separate the state and logic that support a view into a separate class named ViewModel using the Prism Library. The view model sits on top of the application data model to provide the state or data needed to support the view, insulating the view from needing to know about the full complexity of the application. The view model also encapsulates the interaction logic for the view that does not directly depend on the view elements themselves. This QuickStart provides a tutorial on implementing the MVVM pattern.

A common approach to designing the views and view models in an MVVM application is the first sketch out or storyboard for what a view looks like on the screen. Then you analyze that screen to identify what properties the view model needs to expose to support the view, without worrying about how that data will get into the view model. After you define what the view model needs to expose to the view and implement that, you can then dive into how to get the data into the view model. Often, this involves the view model calling to a service to retrieve the data, and sometimes data can be pushed into a view model from some other code such as an application controller.

This QuickStart leads you through the following steps:

  • Analyzing the view to decide what state is needed from a view model to support it
  • Defining the view model class with the minimum implementation to support the view
  • Defining the bindings in the view that point to view model properties
  • Attaching the view to the view model

..."

Finally:

That should be enough Prism for WPF to get you started at least...

Thursday, March 20, 2014

MEF'ing with WP8 (or Now you're "cooking with MEF")

.Netitude - WP8 Breaks Bad (cooking with MEF)

Microsoft’s Managed Extensibility Framework is somewhat of an unsung hero in the .Net world in my opinion. The framework itself is insanely powerful and magical but when you combine it with other patterns and frameworks like MVVM it becomes pure sorcery. If you haven’t checked out MEFedMVVM, I suggest doing so after you get up to speed on MEF and what it is and offers you as a developer.

Recently, the DotNet team announced an update to their Microsoft.Composition nuGet package (MEF 2) which brings MEF-ability to Windows Phone 8.

To understand what MEF proper (ie: full-blown on the desktop) is and how you can use it, there are numerous examples throughout the interwebs. Check out this one and this one for a good start/overview.

What I couldn’t find, however, were actual code examples of using it on Windows Store or Windows Phone apps. The Windows Store support has existed for a few months now, so that surprised me. Let there be light!

(more…)

image

...

Now imagine that you separate out your classes to other assemblies, or simply add new classes to one folder w/in your project. The ease with which you can now add and remove features and objects to your applications becomes MUCH greater, and your confidence in your changes goes up dramatically – you know that you *only* added a feature, you didn’t muck with the view, change the view model, write a bunch more code, just added a new class.

Go forth and cook your apps with MEF!

.NET Framework Blog - Upcoming .NET NuGet Releases

We recently concluded a planning exercise for the next few months of work. From this exercise, we’d like to share the next set of NuGet releases that we plan to do. We chose this particular set based on your feedback and internal partner requests.

All of these packages will be released as pre-release packages on nuget.org.

image

Mostly I just love Brandon's post title... but this is also good news for WP8 dev's. MEF is a great framework and it can really help you build plug-in'able app's.

Thursday, April 11, 2013

Unity vs. MEF - right for you, one is...

Visual Studio Magazine - Unity vs. MEF: Picking the Right Dependency Injection Manager

Peter Vogel compares both of the Microsoft dependency injection managers/inversion of control containers and comes up with a decision tree for picking the correct one.

I think dependency injection containers make it so much easier to implement designs that include many dedicated objects that I'm not sure I could live without one anymore. Microsoft, though, provides two: the Managed Extensibility Framework (MEF), which is part of the Microsoft .NET Framework, and the Unity Container (Unity), which is available as a NuGet download. While there are also several open source tools available, these are the two that are easiest to add to your project. So the question is: Which should you use?

I've discussed MEF and Unity separately, but it's worthwhile to take the time to discuss what I like about each of them and when to use each. One caveat: Both tools are sufficiently "feature rich" that I'm almost certain to get something wrong. I hope comments on this article will address any glaring errors on my part.

First, an overview: Both tools allow you to define containers that you can load with classes or objects. Once you load a container with classes, both frameworks will instantiate the classes and hand you back the resulting objects. Both frameworks allow you to specify what values are to be passed to constructors or used to set properties and call methods when classes are instantiated. Both containers allow you to control the lifetime of those objects -- allowing you, for instance, to specify that only a single instance of some object is ever to be created (effectively implementing the singleton pattern).

...

Unity vs. MEF: The Decision Tree

...

The good news is both MEF and Unity are excellent tools, so neither is a bad choice. The bad news is, three months after picking one, you'll run into a problem that would've been easier to solve with the other tool.

image

Peter's closing sentence made me laugh out loud. So, so true.

Currently I'm on the Unity track as I'm building a Prism app, and it seemed the Unity extensions just felt more natural.

Tuesday, August 21, 2012

I've got your new TPL [Report] right here... TPL Dataflow and MEF 4.5 RTM NuGets released

Base Class Library Blog - MEF and TPL Dataflow NuGet Packages for .NET Framework 4.5

Last week we released .NET Framework 4.5. Today we are happy to announce the release of the RTM versions of the MEF and TPL Dataflow NuGet packages, as promised.

Changes

Our pre-release versions were already in an excellent shape so we didn’t have to change much. In fact, there are no surface area changes and no behavioral changes. We updated a few strings to align with some branding changes (in case you didn’t notice: “Metro style apps” are now called “Windows Store apps”).

However, we added one feature we believe is worth discussing in more detail: we now provide a  symbol package for MEF.

What are symbol packages?

If you read our .NET 4.5 release announcement carefully, you noticed that we also updated the reference source that allows you to debug the source code of the .NET Framework. Scott Guthrie discussed this in detail here. For out-of-band releases we thought it doesn’t make much sense to publish our source as part of the .NET Framework reference sources drop because one of the goals of releasing out-of-band is being able to publish more frequently than the .NET Framework itself.

Instead, we decided to take advantage of NuGet’s symbol packages. In a nutshell, symbol packages allow Visual Studio to find .pdbs and sources for a given binary.

So let’s have a look at how debugging MEF with the NuGet symbol package would look like.

...

image..."

It's great to see these released via NuGet . VS2012 is THE NuGet release and will finally bring NuGet use into the LOB mainstream.

 

Related Past Post XRef:
TPL (Task Parallel Library) Dataflow CTP Released

Stephen Toub says, "I've got your Samples for Parallel Programming with the .NET... right here..."
A Plethora Parallel Programming PDF’s - 12 Parallel Programming with the .NET Framework 4 articles for download
The Coffee Table Guide of the Parallel Programming Samples for .NET 4
Extra .Net 4 Parallel Extension goodness in the Parallel Extension Samples, with RTM updates and a few new Projects
“Samples for Parallel Programming with the .NET Framework 4” gets some VB love…
[Insert Three Hour Tour and/or TPL Report Joke Here] - “A Tour of Various TPL Options” – 28 page free ebook about parallel programming options in .Net via the Task Parallel Library (TPL)
TPL (That is, Task Parallel Library) Article of the Day: “Parent-Child Task Relationships in the .Net Framework 4”
“Samples for Parallel Programming with the .NET Framework 4” gets some VB love…
[.Net 4.0]: Get your Parallel Extensions here… All baked in and part of the Core…. Get your Task Parallel Library here…

You've got your TPL in my MEF. No, you've got your MEF in my TPL...

Thursday, May 03, 2012

From Zero to MEF'tastic... (Or Dummies Guide To MEF Or Learn to MEF in 21 [or less] Pages)

CodeProject - From Zero to Proficient with MEF

"Learn how to go from being an absolute beginner in the Managed Extensibility Framework to being an advanced user.

Introduction

Why is it that when we look for a new laptop, we look at the types of ports it has?Not only do we put up with these holes in the sides of our new laptops, we complain if there aren’t enough of them.The answer, of course, is that these ports allow us to extend our laptop.We can add a second monitor, an external hard drive, or a number of other devices.This doesn’t mean that the original laptop is inferior; it just means that different use cases lend themselves to different configurations.So why is it that -  we insist on making applications without “ports”?

In .NET 4.0, Microsoft provided us with the Managed Extensibility Framework (MEF).This framework allows us to easily create extensibility points (ports) in our applications.The most obvious use for this is for plug-ins.You could allow a customer to create their own menu items just like they can do in Microsoft Word or Visual Studio.However, there are other uses for MEF as well.For example, if you expect business rules might be changed or expanded in the future (that never happens, right?), you could use MEF to make this process simple.I’ll show you how below.

Target Audience

When I first started learning how to use MEF, there were a number of resources that helped me.I found practical articles that showed me how to use the framework in a real application and I found technical articles that explained certain features in great length.What I never seemed to find was that one article that was both practical and in-depth.I ended up going from source to source, picking bits and pieces from each.

This article is intended to be that in-depth look at what MEF in a practical manner.I will attempt to walk you through MEF from start to finish.Along the way I will build example applications so you can see exactly how each feature works.For those of you who are familiar with MEF, this article is broken up by feature so that you can quickly get to just the area you need help with.

...

image..."

I thought this a great article for anyone who's interesting in learning about MEF...

Saturday, April 21, 2012

MEF Review OR If you're building your own custom plug-in frameworks and not using MEF, you might be a ...

Software Rockstar - MEF: Easily Creating Plug-in Based Apps In .NET

"MEF (Managed Extensibility Framework) is an awesome framework that allows easily loading types at runtime making your apps plugin-ready. Using reflection magic, MEF makes it super easy for any app to accept plugins.

Following are 5 easy steps involved in making your app plugin-ready using MEF:

  1. Define an interface for plugins. This is the interface that each plugin must implement.
  2. Define a metadata interface. This interface tells your app out of so many plugins which one is the correct plugin for a given piece of functionality.
  3. Define one or more concrete plugin classes.
  4. Decorate each class with some attributes.
  5. In your app write a few lines of code to invoke MEF, and let the magic happen.

While it may not be very useful in the real world, let’s say that we have an extensible app that can write provided text to Console using different styles. For example input string of “style=warning|This is a warning!” will reproduce text “This is a warning” with red background and white foreground colors. Since our app is extensible we can create new style plugins at any time, place them in appropriate folder, and start using new styles without ever having to recompile our main app.

...

image..."

I know everyone reading my blog already knows about MEF, right? And instead of building your own plugin, app extension, etc. frameworks, you've long moved to MEF? That you've seen just how awesome MEF is by how it's used in Visual Studio 2010? Well then this post isn't for you...

This post is for those new to my blog, those that might not know about MEF like you do. Those that might have heard of MEF, but haven't yet had a chance to check it out. For those who are looking for a quick, just-in-time, info-dump on how to get started using it, to start using it today. This post is for you...

Wednesday, April 18, 2012

A Beginners Guide for MEF 2 (Preview)

CodeProject - MEF 2 Preview Beginners Guide

"Introduction

This is the year all .NET developers will be licking there lips at the excitement and anticipation around yet another version release of our beloved framework of choice. So in the spirit of all things new and exciting. Today I'll be discussing one of my favourites MEF. We all know about MEF's sheer ability to bring about simplicity in implementation, in a development environment defined by complexities, on a day to day basis. Firstly I will be discussing the key features that have been added to MEF2 so far, that I think will make a massive impact upon the release of .NET 4.5. However please note this is more of a sneak peek and not all of what I show you will be in the final version. At time of writing this article the current MEF 2 version is Preview. The new features that will be discussed include The ExportFactory<T> and the new registration API called the RegistrationBuilder to name a few. So let's dive in.

Background

This is a beginners' guide to quickly get you familiar to some of the key changes that have been implemented in MEF 2. So you can start using the preview version straight away with no additional research and understanding.

Setting it all up

Firstly for those of you who have already used the first iteration of MEF, you will have noticed a few distinct differences between the first release and the new upcoming release. One of the subtle changes is all the common export catalogs; now contain an additional constructor overload. This parameter argument is for a new class called the RegistrationBuilder. This class handles the registration of all your exports and part creation through the RegistrationBuilders rich API. So you no longer need to worry about placing attributes on all your dependencies. This was a great move by the team who developed MEF, because MEF’s main role is to provide an easy implementation of dependency injected types for loosely coupled architecture and extensible projects. Any developer extending the functionality of a project doesn’t have to now worry about setting up attributes on the objects he or she wishes to inject. Let’s jump into an example setup below; As you can see in the code snippet below MEF is more flexible with its object lifetime management, as well as the other new features I mentioned above. Now that you are completely bored with me rambling on let me show you how the container and a simple export is set up.

...

image..."

I thought this a very good introduction to MEF 2 and appreciated its comparisons to MEF 1 (This is how you did it before, this is how you can do it now...). If you MEF, you should give this a read...

Wednesday, February 15, 2012

You've got your TPL in my MEF. No, you've got your MEF in my TPL...

Code Guru - .NET Workload Indirection with Managed Extensibility Framework and Task Parallel Library

"Applications like Windows Services and Web Services often have a demanding workload and sophisticated extensibility needs. Managing a workload on the .NET platform often means utilizing the Task Parallel Library (TPL) classes. .NET extensibility capabilities span many components, but increasingly popular extensibility features are found in the Managed Extensibility Framework (MEF). Bringing TPL and MEF together is this article's focus. Walking through a sample application, I'll demonstrate a loosely coupled and extensible TPL and MEF solution.

...

image..."

An interesting mix of MEF and the TPL that I want to take a closer look at...

Friday, December 30, 2011

Visual Studio 2010 and .NET Framework 4 Training Kit December 2011 Release (Think "MVC3 VB and OData HOL Love" version)

Microsoft Downloads - Visual Studio 2010 and .NET Framework 4 Training Kit December 2011 Release

Version: 2.2
Date Published: 12/30/2011

Language: English

VS2010TrainingKitDecember2011.Setup.exe, 497.7 MB

The Visual Studio 2010 and .NET Framework 4 Training Kit includes presentations, hands-on labs, and demos. This content is designed to help you learn how to utilize the Visual Studio 2010 features and a variety of framework technologies including:

  • C# 4
  • Visual Basic 10
  • F#
  • Parallel Extensions
  • Windows Communication Foundation
  • Windows Workflow
  • Windows Presentation Foundation
  • Silverlight 4
  • ASP.NET 4
  • Windows 7
  • Entity Framework
  • ADO.NET Data Services
  • Managed Extensibility Framework
  • Application Lifecycle Management
  • Windows Azure
This version of the Training Kit works with Visual Studio 2010 and .NET Framework 4.

..."

Updates in this release;

  • [New] Visual Basic versions of all MVC3 hands on labs
  • [New] Building Applications and Services Using Open Data Protocol hands-on lab
  • [Removed] Introduction to ADO.NET Data Services hands-on lab 

SNAGHTML1ddb4bfa

And a full span of the page;

image

And my usual WinDirStat snap (showing the VB love in the Kit :)

SNAGHTML1de412b2

 

Related Past Post XRef:
June 2011 release of the Visual Studio 2010 and .NET Framework 4 Training Kit (aka v2.0... or double the download size from the Feb 2010 release, or now 1.8GB of offline training, labs, information, goodness)
Visual Studio 2010 and .NET Framework 4 Training Kit – February Release (aka the VS2010 RC Compatible release) – We’re talking 602MB of VS/.Net training stuff here…
Visual Studio 2010 and .NET Framework 4 Training Kit - October Preview (aka VS2010 B2 version) released
A little VS2010/.Net 4 Training Kit with your Beta 1?

Thursday, June 30, 2011

June 2011 release of the Visual Studio 2010 and .NET Framework 4 Training Kit (aka v2.0... or double the download size from the Feb 2010 release, or now 1.8GB of offline training, labs, information, goodness)

Microsoft Downloads - Visual Studio 2010 and .NET Framework 4 Training Kit June 2011 Release

"Quick details

Version:  2.0
Date Published: 6/28/2011
Language: English

File Name:  VS2010TrainingKitJune2011.Setup.exe
Size: 421.0 MB

Overview

The Visual Studio 2010 and .NET Framework 4 Training Kit includes presentations, hands-on labs, and demos. This content is designed to help you learn how to utilize the Visual Studio 2010 features and a variety of framework technologies including:

  • C# 4
  • Visual Basic 10
  • F#
  • Parallel Extensions
  • Windows Communication Foundation
  • Windows Workflow
  • Windows Presentation Foundation
  • Silverlight 4
  • ASP.NET 4
  • Windows 7
  • Entity Framework
  • ADO.NET Data Services
  • Managed Extensibility Framework
  • Application Lifecycle Management
  • Windows Azure

This version of the Training Kit works with Visual Studio 2010 and .NET Framework 4.

..."

The last time I blogged about this training kit, Visual Studio 2010 and .NET Framework 4 Training Kit – February Release (aka the VS2010 RC Compatible release) – We’re talking 602MB of VS/.Net training stuff here…, the download size was 193MB, 602MB uncompressed. Now the download size is 423MB and 1.8GB uncompressed (wow, 3x's)

In short, if you're looking to learn about anything in the above list, this is a must download/use resource.

<whine> I really wish there was an easy to find "what's new" page/list/information/etc. It would really help those of us who get every release to know what's, well, new...</whine>

Here's a snap of the landing page;

image

And a monster pic/overview of all the items;

image

Finally a WinDirStat image of the install (looks like lots of databases/MDF's doesn't it?);

image

 

Related Past Post XRef:
Visual Studio 2010 and .NET Framework 4 Training Kit – February Release (aka the VS2010 RC Compatible release) – We’re talking 602MB of VS/.Net training stuff here…
Visual Studio 2010 and .NET Framework 4 Training Kit - October Preview (aka VS2010 B2 version) released
A little VS2010/.Net 4 Training Kit with your Beta 1?

Thursday, February 24, 2011

Adding a Private Gallery tab to the Visual Studio 2010 Extension Manager

Visual Studio Gallery - PrivateGalleryPackage

"Add a new tab in the Visual Studio extension manager dialog window to manage private extensions outside the visual studio public gallery. Source code for client and server in available on codeplex ..."

CodePlex - Visual Studio Private Extension Gallery

Overview
Extension manager uses intensively MEF to manage extensions in Visual Studio. This technology can be used too to extend the Extension Manager Window by implementing the Microsoft.VisualStudio.ExtensionManager.IVsEtensionManagerDialogProvider with an export MEF attribute.

Implementing this interface is not very trivial so this project uses some codes from an older Nuget project version.

A basic server implementation is also provided.

You can change repository server address with the options page.

Note : Take into account that the project uses assemblies located in the Visual Studio Private Assemblies which are unsupported assemblies and can be change without notifications in future visual studio version.

..."

Before:

image

After:

image

The CodePlex project includes the VISX,  and the server side setup (i.e. the Private Gallery you host) and source for both.

SNAGHTML28498c79

Monday, June 14, 2010

The Managed Menu Extension (MME) makes adding right click menus to VS2010 simple and easy (via MEF)

Visual Studio Gallery - Managed Menu Extension (MME)

“Back in 2007 I created the project http://managedmenuextension.codeplex.com to make it easier to create custom menu items in the Solution Explorer of Visual Studio 2008. Back then I used the brand new System.AddIn namespace also known as MAF to accomplish this goal.

Now I have upgraded this project to Visual Studio 2010. It is re-developed from the ground up since I now use MEF instead of MAF. MEF has allowed me to make it even easier to create menu items for the solution explorer.

MAF has some advantages over MEF like better Isolation through use of different AppDomains, and an advanced versioning model. But MAF is more complex and I believe not needed for most scenarios involving right click menus. That's is why I went with MEF instead.

Features

  1. Hides Complexity. Installs a Visual Studio Add-In which works behind the scenes and uses MEF to load extensions.
  2. Ease of use. You just implement one interface, IMenuManager which contains 2 methods and place the resulting assembly in a directory.
  3. More powerful. The full DTE object is passed to the implemented IMenuManager if you need it. But you can also use the simpler model you (may) know from Managed Menu Extensions.
  4. One installer. Though I also provide a separate Project Template on the Visual Studio Gallery.
  5. Simple. My ambitions was to provide MenuItems for all kinds of things. Windows Explorer, SharpDevelop and others. But in this edition I focus on the prime target Visual Studio 2010.

Installing your own Menu Extension

When you have created an assembly containing one or more classes implementing IMenuManager, you have to place it in 1 of 3 locations:

  1. You can place it in the same folder as a Visual Studio Solution file (.sln). In this case the Menus will only appear when you open that solution. 
  2. You can place it one folder level above one or more solution files. Then the menus will appear in all the solutions of the subfolders. 
  3. You can place it in the MME subfolder of the CommonAppDataFolder (typically C:\ProgramData\MME). Then the menus appear in all solutions on the machine.

…” [GD: Description Leach Level: 99%]

Visual Studio Gallery - MME MenuManager Template

“This template requires that you have installed MME. MME can either be installed from Visual Studio Gallery via the Extension Manager or from the downloads page of http://mme.codeplex.com.

After installation of this template it is very easy to add a new project to implement Managed Menu Extensions.

Just Choose "Add New Project" and then Visual C# -> Extensibility -> Managed Menu Extension

A Managed Menu Extension is a right click menu for the Visual Studio explorer. You will not believe how easy it is to use. Just implement the 2 methods of the IMenuManager interface, and place the resulting dll in one of 3 locations. …”

CodePlex - Managed Menu Extensions (MME)

“New Edition of Managed Menu Extensions for Visual Studio 2010

The Main goal of "MME" is to provide easy access to adding Right Click menus in the Visual Studio Solution Explorer.

This is accomplished using MEF. All you have to do is implement a simple interface with 2 methods.

…”

A couple things I dig about this. The fact that you can add Solution specific menus I thought was very cool. This way the “menus” can be checked in along with the source making it very easy to keep your entire team in sync.

The second, that the source is available. Many/most of us stand on the shoulders of others and when you make your source code available you are giving back, paying it forward, being the shoulders for others to stand on…

Friday, May 14, 2010

MEF’ing in VB and SilverLight 4, with a little MVVM thrown in for flavor, from Glenn Block

Glenn Block - Hello MEF in Silverlight 4 and VB! (with an MVVM Light cameo)

“For a while we’ve been getting a number of requests to have some MEF samples in VB. Let me first apologize as it’s been something I’ve been meaning to do for a very long time. To partially redeem myself, I’ve gone ahead and ported my Hello MEF sample which I demonstrated at PDC and had a small blog series on. BTW, I won’t blame you if you are not ready to forgive me for not showing VB love earlier. ;-)

The “app” (If you squint you might think it’s a real app :-) ) is an illustration of building a pluggable dashboard with MEF. The sample illustrates a ton of concepts around MEF, but the app itself is quite simple to grock.

  • How to declare exports and imports
  • How to import collections
  • How to lazily instantiate parts
  • How to create custom MEF export attributes
  • How to use MEF metadata for self-describing your MEF components and how you access it.
  • How to use MEF from within XAML (i.e. imports satisfied on parts that are created by the xaml partser).
  • How to apply the View Model (my shorthand for MVVM)  pattern with MEF
  • How to partition you MEF applications across multiple XAPs
  • How to override the default MEF configuration.
  • How to use MVVM Light’s RelayCommand for simple commanding.

And much much more:

I warn though that I am going to be moving pretty fast, so hold on tight!

image …”

MEF = Cool

VB = Cool

MEF + VB = Cool Cool! :p

 

Related Past Post XRef:
The Redmond Developer & Kathleen Dollard get MEF’ed with VB

SilverLight 4, RIA Services, MEF and MVVM, oh my… A four part series from the mind of Shawn Wildermuth (updated for VS2010/SL4 RTM)
10 MEF’Tastic reasons to use MEF – If you’re writing your own “plugin” framework, stop now and check out MEF now (you won’t likely be sorry)
Coding plugin support into your app, because coding is for fun!
Plug into MEF in 10 minutes or less
Best of UK MSDN Flash 2009 eBook
Bart’s Beautiful and Benevolent Personally Guided, “from the Why to the How,” Tour of MEF – The 30+ page tome edition (aka INSERT MEF.* INTO Your.Brain)
Fan (i.e. someone not on the team) MEF Tutorial and Hands On Lab
Getting MEF’ed in 20’ish lines of code - A short and code focused MEF introduction
Managed Extensibility Framework (MEF) CTP2 Released – Now with the full source
The Managed Extensibility Framework (MEF) CTP Released (Not to be confused with the Managed Addin Framework [MAF] which became System.Addin)

Saturday, April 17, 2010

SilverLight 4, RIA Services, MEF and MVVM, oh my… A four part series from the mind of Shawn Wildermuth (updated for VS2010/SL4 RTM)

Shawn Wildermuth - Updated RIA Services + MVVM Example

“A few months I wrote a series of articles on using RIA Services in a structured MVVM application. The article series was more of a thinking-out-loud exercise than a tutorial, but it makes and interesting read. Here are the four parts:

  • Part 1
  • Part 2
  • Part 3
  • Part 4
  • Now that Visual Studio 2010 and Silverlight 4 have RTM'd.  I've updated the example to the latest bits.  You can get it here:

    …”

    Shawn Wildermuth - Architecting Silverlight 4 with RIA Services, MEF and MVVM - Part 1

    “Recently I blogged about Brad Abrams' PDC RIA Services Talk and complained about the data source functionality. While the drag-n-drop ability in RIA Services is interesting, I believe that it may be a bad approach for all but the smallest of projects (or one-off projects). In that comments of that article, I promised to show you how I would architect a Silverlight solution with RIA Services.

    The outcome of that work is a sample that I will cover in a series of blog posts (starting with this one) to explain not only how i'd use RIA Services in Silverlight 4, but also how to solve some of the basic difficulties with those types of architectures. I will be covering how I integrated the Managed Extensibility Framework (MEF) and Laurent Bugnion's MVVM Light Framework to stitch together a loosely coupled Silverlight application.  But let's start with RIA Services.

    image

    …”

    Shawn Wildermuth - Architecting SL4 Applications with RIA Services, MEF and MVVM - Part 2

    “If you've been following this blog, you know that earlier this week I released the first part of the series oon how to architect your Silverlight 4 projects. In this second part, I want to show you how the Managed Extensibility Framework (MEF) can aid in that process.

    …”

    Shawn Wildermuth - Architecting SL4 Applications with RIA Services, MEF and MVVM - Part 3

    “In the first part of this series, I looked at how WCF RIA Services can work in an MVVM architecture. In the second part, I looked at how you could use the Managed Extensibility Framework (MEF) to aid in composing an MVVM application. Now comes the third and last part of the series.  In this part, I will focus on some common problems integrating MVVM and composed user interfaces (that are common to most of these situations, not just using WCF RIA Services). I will show you some refactoring of the MEF design from last article as well as show you how using a framework (I used Laurent Bugnion's MVVM Light framework (v3 Alpha)) can help you smooth out the rough edges of implementing MVVM.

    …”

    Shawn Wildermuth - Architecting SL4 Apps with RIA Services, MEF and MVVM - Part 4 (of 3)

    “Welcome the part 4 of my three-part series on architecting with RIA Services. In the last part of the series, I thought I was done with the example and some of my readers challenged me to help them understand how to handle Add/Delete scenarios. Since I was at it, I figured I should show paging and IsDirty scenarios as well, I decided to make a part four.

    Remember this example is based on my current thoughts, its not dogma. I will change my mind at times and learn from the community (as has even happened during this series).  Hopefully this example can help you think about how the patterns match your current business problems. No tithe, no sermon, no damnation....I promise ;)

    …”

    Shawn’s style is refreshing (i.e. hey, this works for me, and it may work for you too. If not, that’s cool too) and I dig the content. RIA Services is interesting and worth watching (and of course MEF/MVVM rock too  :)

    Friday, April 09, 2010

    10 MEF’Tastic reasons to use MEF – If you’re writing your own “plugin” framework, stop now and check out MEF now (you won’t likely be sorry)

    Jeremy Likness' Blog - Ten Reasons to use the Managed Extensibility Framework

    “One question I'm commonly asked is, "Why do I need the Managed Extensibility Framework? How do I know when to use it?" In addition to that really being two questions, I'm not sure I can tell you the top ten reasons to use MEF or whether or not it is the right tool for you. Instead, as a hands-on consultant who has been using MEF in production applications since the earlier previews, I can share ten reasons why I've used it in my development projects and prefer it over over other frameworks.

    Reason One: It's out of the box.

    image

    …”

    I find it interesting that it seems that MEF isn’t getting more “airplay”. When I ask around the office, “You’re doing Plugin’s… Have you heard of MEF?” I get, “???”

    Now I totally understand that not everyone is a news hound like me, enjoys keeping up with the very latest news and developments, but still… I feel that MEF is going to enable foundational changes to how we, the general Line of Business app developers, design, build and maintain our applications. We all like “addin’s/Plug-in’s” right? We all see the power and flexibility they provide? Don’t you want to include that kind of thing in YOUR applications? The stop reading this and go check out MEF… Now…

     

    Related Past Post XRef:
    Coding plugin support into your app, because coding is for fun!
    Plug into MEF in 10 minutes or less
    Best of UK MSDN Flash 2009 eBook
    Bart’s Beautiful and Benevolent Personally Guided, “from the Why to the How,” Tour of MEF – The 30+ page tome edition (aka INSERT MEF.* INTO Your.Brain)
    Fan (i.e. someone not on the team) MEF Tutorial and Hands On Lab
    Getting MEF’ed in 20’ish lines of code - A short and code focused MEF introduction
    The Redmond Developer & Kathleen Dollard get MEF’ed with VB
    Managed Extensibility Framework (MEF) CTP2 Released – Now with the full source
    The Managed Extensibility Framework (MEF) CTP Released (Not to be confused with the Managed Addin Framework [MAF] which became System.Addin)

    Monday, December 28, 2009

    Coding plugin support into your app, because coding is for fun!

    Coding4Fun - Creating An Application With Full Plug-in Support

    “In this article, you’ll learn how to create an application with full plug-in support.

    Arian T. Kulp www.ariankulp.com

    Project site: http://utilrunner.codeplex.com/
    Code It:
    Downloads
    Run It: Downloads

    Difficulty: Intermediate
    Time Required: 3 hours
    Cost: Free!
    Software Needed: Visual C# 2008 Express Edition or higher

    Introduction

    It’s been a number of months since I released the first version of my Utility Runner application. Utility Runner makes it possible to run system utilities with as little overhead as possible: Instead of lots of tray icons, numerous EXE’s, and the associated memory and startup time overhead, this application manages multiple utilities from one place.

    To open this solution, you’ll need Visual Studio 2008 Express Edition (Visual C# or Visual Basic), at least. If you don’t have it yet, you should get it!

    Working with MEF

    Little has changed functionally from the last version of the application, beyond some refactoring that’s taken place since the new version of MEF was released. For one thing, the attribute for marking an export is no longer sealed, so you can now create a subclassed attribute that encompasses the export name and any other metadata included with it. Consumers can simply use your new custom attribute for a stronger-typed experience. In my case, I created a WpfServiceMetadata class. Read on for more information.

    Managing Addins

    My big challenge was figuring out how to implement an addin manager to support multiple utility addins, like in Firefox. …

    image

    …”

    Why add plug-in capability into your apps? Well, um… duh? How many apps, programs and/or devices do you use because you can extend or add functionality to it? Yeah, like all of them (or so you probably wish ;)

    So it’s time for you to really start thinking about YOUR app’s and how easy you or your users can extend them. This article may very well help you in this endeavor…

    Wednesday, December 16, 2009

    Best of UK MSDN Flash 2009 eBook

    Goto 100 - Development with Visual Basic - FREE MSDN Flash eBook of the best 13 technical articles of 2009

    “…

    The UK MSDN Flash developer newsletter contains great short technical articles written by UK developers both inside Microsoft and in the broader developer community. This eBook pulls together these great articles in one place. There are thirteen articles in this second edition covering Python, Inversion of Control, Behavior Driven Development, Silverlight and more.

    …”

    Snap of the cover;

    image

    From the Table of Contents;

    “…

    VISUAL STUDIO AND .NET FRAMEWORK

    Memory Maped Files with .NET Framework 4.0

    LANGUAGES 7

    Why IronPython?

    TOOLS AND DEVELOPMENT PRACTICES

    Why do I need an Inversion of Control Container?

    Technical Debt

    Neural Networks

    Getting Started with the Managed Extensibility Framework

    Is BDD just TDD with a different name?

    Test Doubles, Mocking and Stubs

    WEB

    ASP.NET 4.0 Web Forms

    CLIENT/OFFICE

    Generate Office 2007 Documents with the help of DocumentReflector

    Model-View-ViewModel gets the most out of WPF and Silverlight

    Consuming real-time data in a Silverlight RIA

    …”

    Some short but cool articles, easily read and consumed.

     

    Related Past Post XRef:
    UK MSDN Flash – Best of 2008 #1 in eBook form

    Monday, November 30, 2009

    Plug into MEF in 10 minutes or less

    Jeremy Likness' Blog - MEF: Build a Plugin in Under 10 Minutes

    “In preparing for an upcoming talk I'll be giving on the Managed Extensibility Framework (MEF), I wanted to demonstrate how fast and easy it is to use in a sample, reference application. This application creates a dynamic plugin. I first link a plugin and show it active, then I create a second plugin and show how it is dynamically added to the program during runtime. It all takes under 10 minutes and would be faster if I didn't want to pace the demo to show the steps involved.

    …” [GD: Click through for the video link]

    MEF rocks and  having it baked into .Net 4 is only icing on the cake. Sure it’s the new kid on the block, but if you’ve ever tried to use the System.Addin model of extending you’re app’s, you’ll thank heaven for MEF.

    Look, if you’re thinking of writing your own plugin/addin/thing, stop. Stop now, don’t go past Go, go directly to MEF… 

    Here’s some MEF posts that caught my eye in the last month’ish (and I’ve been meaning to blog about but…);

     

    Related Past Post XRef:
    Bart’s Beautiful and Benevolent Personally Guided, “from the Why to the How,” Tour of MEF – The 30+ page tome edition (aka INSERT MEF.* INTO Your.Brain)
    Fan (i.e. someone not on the team) MEF Tutorial and Hands On Lab
    Getting MEF’ed in 20’ish lines of code - A short and code focused MEF introduction
    The Redmond Developer & Kathleen Dollard get MEF’ed with VB
    Managed Extensibility Framework (MEF) CTP2 Released – Now with the full source
    The Managed Extensibility Framework (MEF) CTP Released (Not to be confused with the Managed Addin Framework [MAF] which became System.Addin)

    Saturday, August 08, 2009

    Bart’s Beautiful and Benevolent Personally Guided, “from the Why to the How,” Tour of MEF – The 30+ page tome edition (aka INSERT MEF.* INTO Your.Brain)

    B# .NET Blog - A Whirlwind Tour through the Managed Extensibility Framework

    “From a hotel lobby in the sunny city of Durban, South-Africa, waiting for my plane transfer after a great TechEd Africa event. Why not write a blog post on one of my talks: the Managed Extensibility Framework, or MEF. As we steam ahead to release .NET 4.0, it’s great to see the amount of new APIs that will make it into this release. I had the opportunity to talk on three of those the past few days:

    • The Dynamic Language Runtime (System.Dynamic) with dynamic support in C# and VB, and dynamic languages like IronPython and IronRuby.
    • New additions for parallel programming (Task Parallel Library, PLINQ, Coordination Data Structures).
    • The Managed Extensibility Framework (System.ComponentModel.Composition).

    …”

    If you’ve been hearing about MEF (and if you’ve been reading my blog, you probably have ;) but still are not sure you get it, or just haven’t had the time to read up on it yet, then read this post. Bart takes you by hand on a personally guide tour of MEF, from the “Why” all the way to the “How.”

    Plus there’s lots of pretty pictures if you have to sell your management team on MEF… ;)

     

    On a related note, if I haven’t said this before, then shame on me, but if you’re a Microsoft focused developer then Bart’s B#.Net Blog is a MUST, got to have it, read (but I’m sure you all know that by now? ). He’s been providing outstanding and in depth information for years now, and like a good wine, the posts are getting better and better over time.

     

    Related Past Post XRef:
    Fan (i.e. someone not on the team) MEF Tutorial and Hands On Lab
    Getting MEF’ed in 20’ish lines of code - A short and code focused MEF introduction
    The Redmond Developer & Kathleen Dollard get MEF’ed with VB
    Managed Extensibility Framework (MEF) CTP2 Released – Now with the full source
    The Managed Extensibility Framework (MEF) CTP Released (Not to be confused with the Managed Addin Framework [MAF] which became System.Addin)

    Friday, June 12, 2009

    Fan (i.e. someone not on the team) MEF Tutorial and Hands On Lab

    Continuously Integrating - MEF Tutorial

    “You know that everyone’s doing it.  MEF is everywhere.  It’s on the streets, the kid down the block is using, it’s easy to make.  It’s practically addictive.

    To get a handle on it I worked through a simple sample of my own and then thought it might make a good one to share so I put together a real quick and dirty hands-on-lab.  The document and code are available from my skydrive here.  Check it out, first one’s free….”

    image

    They, and I, say that the best way to learn something is to teach it. Well Larry has taken that message and turned it into a quick and dirty MEF HOL with source and shared it with us! Yeah, sharing!  :)

    MEF is a topic we’re actually going to get sick of hearing about, it’s sounds so cool, so many are starting to use it and it seems to easy (compared to other like implementations) that everyone is going to do it. And talk about it. And talk more about it. And… and… until we’re MEF’ed out.

    But until them, here you go.  ;)