tags:

views:

46

answers:

2

I am trying to follow some starter guides for using MEF in .Net 4, but I get stuck when I get to setting up the application. The instructions say to do this:

var catalog = new DirectoryCatalog(@".\");
var container = new CompositionContainer(catalog);
container.Composeparts(this);

But the version of System.ComponentModel.Composition included with .Net 4 doesn't seem to have the Composeparts method available on CompositionContainer, and I am unable to find a good reference on how to do this in the current system.

Here is the reference I am currently using: Building Composable Apps in .NET 4 with the Managed Extensibility Framework

Does anyone out there have a better reference that I should be looking at?

+2  A: 

The CompositionContainer does have a ComposeParts method, as an extension method.

See this reference for some working code.

Ando
A: 

One thing to note, if you haven't used extension methods before. You MUST have the using statement. In this case:

using System.ComponentModel.Composition;

for the code in the question to work. Without the using statement, the intellisense and compiler will not allow the use of the extension method.

Paul Osterhout